Hi all;
I originally wanted to post this has a Help issue on GitHub for the NextJS package but got redirected here. Either way, here’s my problem.
During the beforeSessionSaved
callback I want to persist some user information to my database using the Drizzle ORM. Unfortunately it seems like Auth0 is overwriting or modifying the URL
global object as when I try to execute the code below I get an error saying “TypeError: URL is not a constructor”, however executing database queries anywhere else in the app seems to work fine.
export const auth0 = new Auth0Client({
beforeSessionSaved: async (session: SessionData) => {
const { sub, username, email, name, picture } = session.user
const attributes = {
id: sub,
avatar: picture,
username,
email,
name
}
await db.insert(users)
.values(attributes)
.onDuplicateKeyUpdate({
set: omit(attributes, ['id'])
})
return session
},
authorizationParameters: {
scope: "openid profile email",
},
})
What’s the recommended approach here so that I don’t clash with the mutated URL
object?
Thanks in advance