fix(frontend): guard redirect callback against undefined url during SSG
Deploy to Production / test (push) Has been cancelled
Deploy to Production / deploy (push) Has been cancelled

This commit is contained in:
Patrick Plate
2026-06-13 09:28:52 +02:00
parent 106229e0e3
commit d650987b9a
+7 -1
View File
@@ -106,10 +106,16 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
return session
},
async redirect({ url, baseUrl }) {
// Guard: url may be undefined during static generation
if (!url) return baseUrl
// Handle relative URLs
if (url.startsWith("/")) return `${baseUrl}${url}`
// Handle same-origin URLs
if (new URL(url).origin === baseUrl) return url
try {
if (new URL(url).origin === baseUrl) return url
} catch {
// Invalid URL — fall back to baseUrl
}
return baseUrl
},
},