fix(auth-js): AUTH_URL not working in getAuthUser (#481)

* fix(auth-js): AUTH_URL not working in getAuthUser

* chore(auth-js): add changeset
pull/485/head
DIYgod 2024-04-29 05:49:15 +01:00 committed by GitHub
parent 319b955c74
commit b8fb9a06c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/auth-js': patch
---
fix AUTH_URL not working in getAuthUser

View File

@ -63,7 +63,7 @@ function setEnvDefaults(env: AuthEnv, config: AuthConfig) {
export async function getAuthUser(c: Context): Promise<AuthUser | null> {
const config = c.get('authConfig')
setEnvDefaults(c.env, config)
const origin = new URL(c.req.url, c.env.AUTH_URL).origin
const origin = c.env.AUTH_URL ? new URL(c.env.AUTH_URL).origin : new URL(c.req.url).origin
const request = new Request(`${origin}${config.basePath}/session`, {
headers: { cookie: c.req.header('cookie') ?? '' },
})