mirror of
https://github.com/kremalicious/umami.git
synced 2024-06-28 00:37:51 +02:00
Changed force SSL method to send headers.
This commit is contained in:
parent
22195a07f9
commit
6eaf090bde
|
@ -1,13 +1,12 @@
|
|||
import { NextResponse } from 'next/server';
|
||||
|
||||
function redirectHTTPS(req) {
|
||||
const host = req.headers.get('host');
|
||||
if (
|
||||
process.env.FORCE_SSL &&
|
||||
process.env.NODE_ENV === 'production' &&
|
||||
req.nextUrl.protocol === 'http:'
|
||||
) {
|
||||
return NextResponse.redirect(`https://${host}${req.nextUrl.pathname}`, 301);
|
||||
function forceSSL(req) {
|
||||
if (process.env.FORCE_SSL && req.nextUrl.protocol === 'http:') {
|
||||
const response = NextResponse.next();
|
||||
|
||||
response.headers.set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +31,7 @@ function disableLogin(req) {
|
|||
}
|
||||
|
||||
export function middleware(req) {
|
||||
const fns = [redirectHTTPS, customScriptName, disableLogin];
|
||||
const fns = [customScriptName, disableLogin, forceSSL];
|
||||
|
||||
for (const fn of fns) {
|
||||
const res = fn(req);
|
||||
|
|
Loading…
Reference in New Issue
Block a user