mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
No https on NS_DEVEL
This commit is contained in:
22
server.js
22
server.js
@@ -89,18 +89,20 @@ function exit (reason) {
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
if (req.secure) {
|
||||
next()
|
||||
} else {
|
||||
logger.DebugLog(`HTTPS ${req.method} redirect to: ${'https://' + req.headers.host + req.url}`, 'https', 1)
|
||||
if (req.method === 'POST') {
|
||||
res.redirect(307, 'https://' + req.headers.host + req.url)
|
||||
if (!process.env.NS_DEVEL) {
|
||||
app.use(function (req, res, next) {
|
||||
if (req.secure) {
|
||||
next()
|
||||
} else {
|
||||
res.redirect('https://' + req.headers.host + req.url)
|
||||
logger.DebugLog(`HTTPS ${req.method} redirect to: ${'https://' + req.headers.host + req.url}`, 'https', 1)
|
||||
if (req.method === 'POST') {
|
||||
res.redirect(307, 'https://' + req.headers.host + req.url)
|
||||
} else {
|
||||
res.redirect('https://' + req.headers.host + req.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
// https://github.com/expressjs/cors#configuration-options
|
||||
app.use(cors({
|
||||
credentials: true,
|
||||
|
Reference in New Issue
Block a user