110110 */
111111
112112import type { AuthConfig } from "@auth/core"
113- import { Auth , isAuthAction , skipCSRFCheck , customFetch } from "@auth/core"
113+ import {
114+ Auth ,
115+ isAuthAction ,
116+ skipCSRFCheck ,
117+ customFetch as _customFetch ,
118+ } from "@auth/core"
114119import { AuthAction , Session } from "@auth/core/types"
115120import { implicit$FirstArg , type QRL } from "@builder.io/qwik"
116121import {
@@ -124,7 +129,8 @@ import { EnvGetter } from "@builder.io/qwik-city/middleware/request-handler"
124129import { isServer } from "@builder.io/qwik/build"
125130import { parseString , splitCookiesString } from "set-cookie-parser"
126131
127- export { customFetch }
132+ export const customFetch = isServer ? _customFetch : undefined
133+
128134export { AuthError , CredentialsSignin } from "@auth/core/errors"
129135
130136export type {
@@ -149,6 +155,7 @@ export function QwikAuthQrl(
149155 { providerId, redirectTo : _redirectTo , options, authorizationParams } ,
150156 req
151157 ) => {
158+ if ( ! isServer ) return
152159 const { redirectTo = _redirectTo ?? defaultRedirectTo ( req ) , ...rest } =
153160 options ?? { }
154161
@@ -192,6 +199,7 @@ export function QwikAuthQrl(
192199
193200 const useSignOut = globalAction$ (
194201 async ( { redirectTo } , req ) => {
202+ if ( ! isServer ) return
195203 redirectTo ??= defaultRedirectTo ( req )
196204 const authOpts = await authOptions ( req )
197205 setEnvDefaults ( req . env , authOpts )
@@ -261,6 +269,7 @@ async function authAction(
261269 path : string ,
262270 authOptions : QwikAuthConfig
263271) {
272+ if ( ! isServer ) return
264273 const request = new Request ( new URL ( path , req . request . url ) , {
265274 method : req . request . method ,
266275 headers : req . request . headers ,
@@ -337,6 +346,7 @@ async function getSessionData(
337346}
338347
339348export const setEnvDefaults = ( env : EnvGetter , config : AuthConfig ) => {
349+ if ( ! isServer ) return
340350 config . basePath = "/auth"
341351 if ( ! config . secret ?. length ) {
342352 config . secret = [ ]
0 commit comments