Running into URL constructor issues when combined with Auth0's NextJS package

Hey all; I'm currently running into some really annoying issues when trying to insert a user into my database once they have been authenticated by Auth0. I'm attempting to do this in the beforeSessionSaved handler within the Auth0Client. I've opened a ticket for them to take a look at but I wondered if there's anything I can do on the Drizzle side? The error I'm seeing is "TypeError: URL is not a constructor" and this only happens when using Drizzle from within the callback.
export const db = drizzle(process.env.DATABASE_URL!, { schema, mode: 'default' })
export const db = drizzle(process.env.DATABASE_URL!, { schema, mode: 'default' })
Here's my example code:
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",
},
})
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",
},
})
Is there another method how I can connect to a MySQL database that doesn't rely on the URL global object? Thanks in advance
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?