diff --git a/apps/web/pages/api/auth/[...nextauth].tsx b/apps/web/pages/api/auth/[...nextauth].tsx index 574951f70e..b30a18a335 100644 --- a/apps/web/pages/api/auth/[...nextauth].tsx +++ b/apps/web/pages/api/auth/[...nextauth].tsx @@ -434,5 +434,12 @@ export default NextAuth({ return false; }, + async redirect({ url, baseUrl }) { + // Allows relative callback URLs + if (url.startsWith("/")) return `${baseUrl}${url}`; + // Allows callback URLs on the same origin + else if (new URL(url).origin === new URL(baseUrl || WEBSITE_URL).origin) return url; + return baseUrl; + }, }, });