Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/runtime/server/services/authjs/nuxtAuthHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ let usedSecret: string | undefined
/** Setup the nuxt (next) auth event handler, based on the passed in options */
export function NuxtAuthHandler(nuxtAuthOptions?: AuthOptions) {
const isProduction = process.env.NODE_ENV === 'production'
const trustHostUserPreference = useTypedBackendConfig(useRuntimeConfig(), 'authjs').trustHost
const runtimeConfig = useRuntimeConfig()
const trustHostUserPreference = useTypedBackendConfig(runtimeConfig, 'authjs').trustHost

usedSecret = nuxtAuthOptions?.secret
if (!usedSecret) {
Expand All @@ -46,7 +47,7 @@ export function NuxtAuthHandler(nuxtAuthOptions?: AuthOptions) {
trustHost: true,

// AuthJS uses `/auth` as default, but we rely on `/api/auth` (same as in previous `next-auth`)
basePath: '/api/auth'
basePath: runtimeConfig.public.auth.baseURL,

// Uncomment to enable framework-author specific functionality
// raw: raw as typeof raw
Expand Down Expand Up @@ -134,7 +135,7 @@ export async function getServerSession(event: H3Event) {
cookies: parseCookies(event),
providerId: undefined,
error: undefined,
host: sessionUrl.origin,
host: sessionUrl.href,
query: Object.fromEntries(sessionUrl.searchParams)
}

Expand Down Expand Up @@ -183,7 +184,7 @@ export function getToken<R extends boolean = false>({ event, secureCookie, secre
*/
async function createRequestForAuthjs(event: H3Event, trustHostUserPreference: boolean): Promise<RequestInternal> {
const nextRequest: Omit<RequestInternal, 'action'> = {
host: getRequestURLFromH3Event(event, trustHostUserPreference).origin,
host: getRequestURLFromH3Event(event, trustHostUserPreference).href,
body: undefined,
cookies: parseCookies(event),
query: undefined,
Expand Down
Loading