Skip to content

Commit f74d139

Browse files
hopefully fix some of the stupid BS
1 parent c1317db commit f74d139

5 files changed

Lines changed: 45 additions & 57 deletions

File tree

pnpm-lock.yaml

Lines changed: 14 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rammerhead/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.2.72
2+
3+
- Hopefully fix the errors when running behind a reverse proxy
4+
15
## v1.2.70
26

37
- Setup folder properly

rammerhead/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rubynetwork/rh",
3-
"version": "1.2.71",
3+
"version": "1.2.72",
44
"description": "User friendly web proxy powered by testcafe-hammerhead",
55
"main": "src/index.js",
66
"type": "module",
@@ -27,6 +27,7 @@
2727
"homepage": "https://github.com/binary-person/rammerhead#readme",
2828
"dependencies": {
2929
"async-exit-hook": "^2.0.1",
30+
"cookie": "^0.7.1",
3031
"lru-cache": "^7.14.1",
3132
"mime": "^2.5.2",
3233
"sticky-session-custom": "^1.2.0",

rammerhead/src/config.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs';
22
import os from 'os';
33
import path from 'path';
4+
import cookie from 'cookie';
45
import RammerheadJSFileCache from './classes/RammerheadJSFileCache.js';
56
import RammerheadJSMemCache from './classes/RammerheadJSMemCache.js';
67

@@ -25,12 +26,29 @@ export default {
2526
// this function's return object will determine how the client url rewriting will work.
2627
// set them differently from bindingAddress and port if rammerhead is being served
2728
// from a reverse proxy.
28-
getServerInfo: () => ({
29-
hostname: 'localhost',
30-
port: 8080,
31-
crossDomainPort: 8081,
32-
protocol: 'http:'
33-
}),
29+
//getServerInfo: () => ({
30+
// hostname: 'localhost',
31+
// port: 8080,
32+
// crossDomainPort: 8081,
33+
// protocol: 'http:'
34+
//}),
35+
getServerInfo: (req) => {
36+
const { origin_proxy } = cookie.parse(req.headers.cookie || '');
37+
let origin;
38+
try {
39+
origin = new URL(origin_proxy);
40+
} catch (err) {
41+
console.log(err, req.headers.cookie);
42+
origin = new URL(`${req.socket.encrypted ? 'https:' : 'http:'}//${req.headers.host}`);
43+
}
44+
const { hostname, port, protocol } = origin;
45+
return {
46+
hostname,
47+
port,
48+
crossDomainPort: port,
49+
protocol
50+
};
51+
},
3452
// example of non-hard-coding the hostname header
3553
// getServerInfo: (req) => {
3654
// return { hostname: new URL('http://' + req.headers.host).hostname, port: 443, crossDomainPort: 8443, protocol: 'https: };

rammerhead/src/setup.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ function setup() {
99
fs.mkdirSync(path.join(import.meta.dirname, '..', 'public'));
1010
}
1111
catch (err) {
12-
//steam roll over errors :D
13-
//console.error('Something went wrong!\n', err)
12+
console.error('Error occured while setting up:', err);
1413
}
1514
}
1615

0 commit comments

Comments
 (0)