case insensitive header
This commit is contained in:
12
app.js
12
app.js
@@ -2,6 +2,13 @@ const express = require('express')
|
||||
const app = express()
|
||||
const port = process.env.PORT || 3000
|
||||
|
||||
app.use((req, res, next) => {
|
||||
const forwardedProto = req.header("X-Forwarded-Proto") || req.protocol
|
||||
console.log(`Incoming Protocol: ${forwardedProto}`)
|
||||
forwardedProto === 'https' ? next() : res.redirect(301, 'https://' + req.headers.host + req.url)
|
||||
})
|
||||
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World!')
|
||||
})
|
||||
@@ -10,8 +17,3 @@ app.listen(port, () => {
|
||||
console.log(`Example app listening at http://localhost:${port}`)
|
||||
})
|
||||
|
||||
app.use((req, res, next) => {
|
||||
const forwardedProto = req.headers["X-Forwarded-Proto"] || req.protocol
|
||||
console.log(forwardedProto)
|
||||
forwardedProto === 'https' ? next() : res.redirect('https://' + req.headers.host + req.url, 301)
|
||||
})
|
||||
Reference in New Issue
Block a user