Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

fix: next auth redirect url to use base domain #153

Merged
merged 1 commit into from May 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions pages/api/auth/[...nextauth].js
Expand Up @@ -98,5 +98,16 @@ export default NextAuth({

return await refreshAccessToken(token);
},
async redirect({ url, baseUrl }) {
// Allows relative callback URLs
if (url.startsWith("/")) return `${baseUrl}${url}`;
// replace origin with baseUrl
// to fix bonkers behavior from next-auth
// fix in the works: https://github.com/nextauthjs/next-auth/pull/4534
const origin = baseUrl;
const urlPath = new URL(url).pathname;
const newPath = `${origin}${urlPath}`;
return newPath;
},
},
});