Skip to content

Commit

Permalink
cloud: Fix x-scrypted-cloud header to come from upstream proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Mar 4, 2023
1 parent 3360779 commit 9eb5029
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions plugins/cloud/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@
"@types/nat-upnp": "^1.1.2",
"@types/node": "^18.11.18"
},
"version": "0.1.12"
"version": "0.1.13"
}
7 changes: 2 additions & 5 deletions plugins/cloud/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,8 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
'X-Forwarded-Proto': 'https',
};

const handlerLog = throttle((req: http.IncomingMessage) => {
this.console.log('Cloud connection:', req.socket?.remoteAddress);
}, 10000)
const handler = async (req: http.IncomingMessage, res: http.ServerResponse) => {
handlerLog(req);
this.console.log('Cloud connection:', req.socket?.remoteAddress, req.url);

const url = Url.parse(req.url);
if (url.path.startsWith('/web/oauth/callback') && url.query) {
Expand Down Expand Up @@ -625,7 +622,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
});
this.proxy.on('error', () => { });
this.proxy.on('proxyRes', (res, req) => {
res.headers['X-Scrypted-Cloud'] = 'true';
res.headers['X-Scrypted-Cloud'] = req.headers['x-scrypted-cloud'];
res.headers['X-Scrypted-Direct-Address'] = req.headers['x-scrypted-direct-address'];
res.headers['Access-Control-Expose-Headers'] = 'X-Scrypted-Cloud, X-Scrypted-Direct-Address';
});
Expand Down

0 comments on commit 9eb5029

Please sign in to comment.