Open
Description
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
Hi all;
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
Reproduction
- Create a basic MySQL Drizzle set up
- Attempt to insert into a table during
beforeSessionSaved
- See NextJS error pointing to Drizzle for a
URL
object error
Additional context
No response
nextjs-auth0 version
4.4.1
Next.js version
15.2.2
Node.js version
18.18.2
Metadata
Metadata
Assignees
Labels
No labels