@@ -24,7 +24,8 @@ let usedSecret: string | undefined
24
24
/** Setup the nuxt (next) auth event handler, based on the passed in options */
25
25
export function NuxtAuthHandler ( nuxtAuthOptions ?: AuthOptions ) {
26
26
const isProduction = process . env . NODE_ENV === 'production'
27
- const trustHostUserPreference = useTypedBackendConfig ( useRuntimeConfig ( ) , 'authjs' ) . trustHost
27
+ const runtimeConfig = useRuntimeConfig ( )
28
+ const trustHostUserPreference = useTypedBackendConfig ( runtimeConfig , 'authjs' ) . trustHost
28
29
29
30
usedSecret = nuxtAuthOptions ?. secret
30
31
if ( ! usedSecret ) {
@@ -46,7 +47,7 @@ export function NuxtAuthHandler(nuxtAuthOptions?: AuthOptions) {
46
47
trustHost : true ,
47
48
48
49
// AuthJS uses `/auth` as default, but we rely on `/api/auth` (same as in previous `next-auth`)
49
- basePath : '/api/ auth'
50
+ basePath : runtimeConfig . public . auth . baseURL ,
50
51
51
52
// Uncomment to enable framework-author specific functionality
52
53
// raw: raw as typeof raw
@@ -134,7 +135,7 @@ export async function getServerSession(event: H3Event) {
134
135
cookies : parseCookies ( event ) ,
135
136
providerId : undefined ,
136
137
error : undefined ,
137
- host : sessionUrl . origin ,
138
+ host : sessionUrl . href ,
138
139
query : Object . fromEntries ( sessionUrl . searchParams )
139
140
}
140
141
@@ -183,7 +184,7 @@ export function getToken<R extends boolean = false>({ event, secureCookie, secre
183
184
*/
184
185
async function createRequestForAuthjs ( event : H3Event , trustHostUserPreference : boolean ) : Promise < RequestInternal > {
185
186
const nextRequest : Omit < RequestInternal , 'action' > = {
186
- host : getRequestURLFromH3Event ( event , trustHostUserPreference ) . origin ,
187
+ host : getRequestURLFromH3Event ( event , trustHostUserPreference ) . href ,
187
188
body : undefined ,
188
189
cookies : parseCookies ( event ) ,
189
190
query : undefined ,
0 commit comments