fix: set cookie in header on rewrite

This commit is contained in:
Christel Westerberg
2024-05-07 12:10:25 +02:00
parent b58b5f368d
commit 777fd1e5b6
4 changed files with 38 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
import { notFound } from "next/navigation"
import { type NextMiddleware, NextResponse } from "next/server"
import { findLang } from "@/constants/languages"
@@ -36,6 +37,8 @@ export const middleware: NextMiddleware = async (request) => {
nextUrl
)
)
} else {
return notFound()
}
}
@@ -69,6 +72,7 @@ export const middleware: NextMiddleware = async (request) => {
{
headers: {
"Set-Cookie": `webviewToken=${decryptedData}; Secure; HttpOnly; Path=/; SameSite=Strict;`,
Cookie: `webviewToken=${decryptedData}`,
},
}
)
@@ -81,6 +85,7 @@ export const middleware: NextMiddleware = async (request) => {
{
headers: {
"Set-Cookie": `webviewToken=${decryptedData}; Secure; HttpOnly; Path=/; SameSite=Strict;`,
Cookie: `webviewToken=${decryptedData}`,
},
}
)