mirror of
https://github.com/kremalicious/umami.git
synced 2024-06-30 13:41:50 +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';
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
function redirectHTTPS(req) {
|
function forceSSL(req) {
|
||||||
const host = req.headers.get('host');
|
if (process.env.FORCE_SSL && req.nextUrl.protocol === 'http:') {
|
||||||
if (
|
const response = NextResponse.next();
|
||||||
process.env.FORCE_SSL &&
|
|
||||||
process.env.NODE_ENV === 'production' &&
|
response.headers.set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
|
||||||
req.nextUrl.protocol === 'http:'
|
|
||||||
) {
|
return response;
|
||||||
return NextResponse.redirect(`https://${host}${req.nextUrl.pathname}`, 301);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ function disableLogin(req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function middleware(req) {
|
export function middleware(req) {
|
||||||
const fns = [redirectHTTPS, customScriptName, disableLogin];
|
const fns = [customScriptName, disableLogin, forceSSL];
|
||||||
|
|
||||||
for (const fn of fns) {
|
for (const fn of fns) {
|
||||||
const res = fn(req);
|
const res = fn(req);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user