fix: add logs

This commit is contained in:
Christel Westerberg
2024-05-17 13:53:47 +02:00
parent e195f70d79
commit d5f2604ca0
3 changed files with 12 additions and 0 deletions

View File

@@ -35,6 +35,8 @@ export function serverClient() {
redirect(redirectUrl)
}
console.error("Unautorized on web, redirecting to login")
const pathname = ctx?.pathname || "/"
redirect(
`/${lang}/login?redirectTo=${encodeURIComponent(`/${lang}/${pathname}`)}`

View File

@@ -35,6 +35,7 @@ export const middleware: NextMiddleware = async (request) => {
const searchParams = new URLSearchParams(request.nextUrl.searchParams)
searchParams.set("uri", pathNameWithoutLang)
const webviewToken = request.cookies.get("webviewToken")
if (webviewToken) {
// since the token exists, this is a subsequent visit
@@ -82,6 +83,8 @@ export const middleware: NextMiddleware = async (request) => {
)
headers.set("Cookie", `webviewToken=${decryptedData}`)
console.log("IN WEBVIEW MIDDLEWARE", decryptedData)
if (myPagesWebviews.includes(nextUrl.pathname)) {
return NextResponse.rewrite(
new URL(

View File

@@ -38,6 +38,13 @@ export function createContext() {
const cookie = cookies()
const webviewTokenCookie = cookie.get("webviewToken")
console.log("IN CONTEXT", {
lang: h.get("x-lang") as Lang,
pathname: h.get("x-pathname")!,
url: h.get("x-url")!,
webviewToken: cookie.get("webviewToken"),
})
return createContextInner({
auth,
lang: h.get("x-lang") as Lang,