Skip to content

Commit 950ebf3

Browse files
authored
fix(prerenderer): configure trust proxy to fix http -> https redirects (#596)
1 parent a88011a commit 950ebf3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

prerender-server/src/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ register.registerMetric(renderDuration)
4242
let requestCounter = 0
4343

4444
const app = express()
45+
app.set('trust proxy', true)
4546
app.engine('pug', pug.__express)
4647

4748
app.get('/metrics', async (req, res) => {
@@ -108,7 +109,7 @@ app.use((req, res, next) => {
108109
totalRenders.inc()
109110
}
110111
if (err) return next(err)
111-
if (resp.redirect) return res.redirect(301, baseHref + resp.redirect.substr(1))
112+
if (resp.redirect) return res.redirect(301, baseHref + resp.redirect)
112113
if (resp.errorCode) {
113114
console.error(`Failed with code ${resp.errorCode}:`, resp)
114115
return res.sendStatus(resp.errorCode)

0 commit comments

Comments
 (0)