Skip to content

Commit 0e1759a

Browse files
committed
Prefer protocol configured in server URI.
The server URI's protocol would be determined based on the protocol of the request only, which could be different if Solid is behind a reverse proxy.
1 parent 1a04fae commit 0e1759a

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)