diff --git a/libraries/helpers/src/utils/custom.fetch.func.ts b/libraries/helpers/src/utils/custom.fetch.func.ts index b4c175b2..c7a563a4 100644 --- a/libraries/helpers/src/utils/custom.fetch.func.ts +++ b/libraries/helpers/src/utils/custom.fetch.func.ts @@ -1,5 +1,3 @@ -'use client'; - export interface Params { baseUrl: string; beforeRequest?: (url: string, options: RequestInit) => Promise; @@ -16,7 +14,7 @@ export const customFetch = ( secured: boolean = true ) => { return async function newFetch(url: string, options: RequestInit = {}) { - const loggedAuth = new URL(window.location.href).searchParams.get( + const loggedAuth = typeof window === "undefined" ? undefined : new URL(window.location.href).searchParams.get( 'loggedAuth' ); const newRequestObject = await params?.beforeRequest?.(url, options); diff --git a/libraries/helpers/src/utils/internal.fetch.ts b/libraries/helpers/src/utils/internal.fetch.ts index 86e6cd38..84006be3 100644 --- a/libraries/helpers/src/utils/internal.fetch.ts +++ b/libraries/helpers/src/utils/internal.fetch.ts @@ -1,5 +1,5 @@ -import { customFetch } from './custom.fetch.func'; import { cookies } from 'next/headers'; +import { customFetch } from '@gitroom/helpers/utils/custom.fetch.func'; export const internalFetch = (url: string, options: RequestInit = {}) => customFetch(