Skip to content

Commit 03428a6

Browse files
Merge pull request #651 from solid/fix/baseuri-behind-proxy
Prefer protocol configured in server URI
2 parents 1a04fae + 0e1759a commit 03428a6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ function filenameToBaseUri (filename, uri, base) {
9999
}
100100

101101
function getBaseUri (req) {
102-
return req.protocol + '://' + req.get('host')
102+
// Obtain the protocol from the configured server URI
103+
// (in case the server is running behind a reverse proxy)
104+
const locals = req.app.locals
105+
const serverUri = locals.host.serverUri
106+
const protocol = serverUri.replace(/:.*/, '')
107+
108+
return `${protocol || req.protocol}://${req.get('host')}`
103109
}
104110

105111
/**

0 commit comments

Comments
 (0)