Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/routes/ui/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export const BASE_URL = process.env.BASE_URL || `http://localhost:${PORT}`;
*/
export function getBaseUrl(req) {
if (process.env.BASE_URL) return process.env.BASE_URL;
const proto = req.headers['x-forwarded-proto'] || req.protocol || 'http';
const host = req.headers['x-forwarded-host'] || req.headers.host || `localhost:${PORT}`;
const isLocal = host.startsWith('localhost') || host.startsWith('127.0.0.1');
const proto = req.headers['x-forwarded-proto'] || (isLocal ? 'http' : 'https');
return `${proto}://${host}`;
}

Expand Down
Loading