diff --git a/packages/frameworks-qwik/src/index.ts b/packages/frameworks-qwik/src/index.ts index 4100cb3f5d..6fecdafd6b 100644 --- a/packages/frameworks-qwik/src/index.ts +++ b/packages/frameworks-qwik/src/index.ts @@ -110,7 +110,12 @@ */ import type { AuthConfig } from "@auth/core" -import { Auth, isAuthAction, skipCSRFCheck, customFetch } from "@auth/core" +import { + Auth, + isAuthAction, + skipCSRFCheck, + customFetch as _customFetch, +} from "@auth/core" import { AuthAction, Session } from "@auth/core/types" import { implicit$FirstArg, type QRL } from "@builder.io/qwik" import { @@ -124,7 +129,8 @@ import { EnvGetter } from "@builder.io/qwik-city/middleware/request-handler" import { isServer } from "@builder.io/qwik/build" import { parseString, splitCookiesString } from "set-cookie-parser" -export { customFetch } +export const customFetch = isServer ? _customFetch : undefined + export { AuthError, CredentialsSignin } from "@auth/core/errors" export type { @@ -149,6 +155,7 @@ export function QwikAuthQrl( { providerId, redirectTo: _redirectTo, options, authorizationParams }, req ) => { + if (!isServer) return const { redirectTo = _redirectTo ?? defaultRedirectTo(req), ...rest } = options ?? {} @@ -192,6 +199,7 @@ export function QwikAuthQrl( const useSignOut = globalAction$( async ({ redirectTo }, req) => { + if (!isServer) return redirectTo ??= defaultRedirectTo(req) const authOpts = await authOptions(req) setEnvDefaults(req.env, authOpts) @@ -261,6 +269,7 @@ async function authAction( path: string, authOptions: QwikAuthConfig ) { + if (!isServer) return const request = new Request(new URL(path, req.request.url), { method: req.request.method, headers: req.request.headers, @@ -337,6 +346,7 @@ async function getSessionData( } export const setEnvDefaults = (env: EnvGetter, config: AuthConfig) => { + if (!isServer) return config.basePath = "/auth" if (!config.secret?.length) { config.secret = []