Skip to content

Commit

Permalink
cloud: prefer cloudflared address if available
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Jul 6, 2024
1 parent d2564ef commit 9dc5f2a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 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 @@ -53,5 +53,5 @@
"@types/nat-upnp": "^1.1.5",
"@types/node": "^20.14.6"
},
"version": "0.2.17"
"version": "0.2.20"
}
5 changes: 2 additions & 3 deletions plugins/cloud/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,9 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
this.proxy.on('proxyRes', (res, req) => {
res.headers['X-Scrypted-Cloud'] = req.headers['x-scrypted-cloud'];
res.headers['X-Scrypted-Direct-Address'] = req.headers['x-scrypted-direct-address'];
let domain: string;
if (this.storageSettings.values.forwardingMode === 'Custom Domain' && this.storageSettings.values.hostname)
let domain = this.cloudflareTunnel;
if (!domain && this.storageSettings.values.forwardingMode === 'Custom Domain' && this.storageSettings.values.hostname)
domain = `https://${this.storageSettings.values.hostname}`;
domain ||= this.cloudflareTunnel;
res.headers['X-Scrypted-Cloud-Address'] = domain;
res.headers['Access-Control-Expose-Headers'] = 'X-Scrypted-Cloud, X-Scrypted-Direct-Address, X-Scrypted-Cloud-Address';
});
Expand Down

0 comments on commit 9dc5f2a

Please sign in to comment.