feat: force https

This commit is contained in:
DIYgod
2022-10-06 03:28:52 +01:00
parent 7d64839311
commit 4b51535858
+9
View File
@@ -15,6 +15,15 @@ const ALWAYS_REPLAY_ROUTES = [
export default async function middleware(req: NextRequest) {
const { pathname } = req.nextUrl
if (IS_PROD && req.headers.get("x-forwarded-proto") !== "https") {
return NextResponse.redirect(
`https://${req.headers.get("host")}${req.nextUrl.pathname}${
req.nextUrl.search
}`,
301,
)
}
console.log(`${req.method} ${req.nextUrl.pathname}${req.nextUrl.search}`)
if (