Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: token

Nevo David5d908470f1e6
diff --git a/libraries/helpers/src/utils/custom.fetch.func.ts b/libraries/helpers/src/utils/custom.fetch.func.ts
index 49ec9a6ae..b4c175b29 100644
--- a/libraries/helpers/src/utils/custom.fetch.func.ts
+++ b/libraries/helpers/src/utils/custom.fetch.func.ts
@@ -1,3 +1,5 @@
+'use client';
+
export interface Params {
baseUrl: string;
beforeRequest?: (url: string, options: RequestInit) => Promise<RequestInit>;
@@ -14,21 +16,33 @@ export const customFetch = (
secured: boolean = true
) => {
return async function newFetch(url: string, options: RequestInit = {}) {
+ const loggedAuth = new URL(window.location.href).searchParams.get(
+ 'loggedAuth'
+ );
const newRequestObject = await params?.beforeRequest?.(url, options);
- const authNonSecuredCookie = typeof document === 'undefined' ? null : document.cookie
- .split(';')
- .find((p) => p.includes('auth='))
- ?.split('=')[1];
+ const authNonSecuredCookie =
+ typeof document === 'undefined'
+ ? null
+ : document.cookie
+ .split(';')
+ .find((p) => p.includes('auth='))
+ ?.split('=')[1];
- const authNonSecuredOrg = typeof document === 'undefined' ? null : document.cookie
- .split(';')
- .find((p) => p.includes('showorg='))
- ?.split('=')[1];
+ const authNonSecuredOrg =
+ typeof document === 'undefined'
+ ? null
+ : document.cookie
+ .split(';')
+ .find((p) => p.includes('showorg='))
+ ?.split('=')[1];
- const authNonSecuredImpersonate = typeof document === 'undefined' ? null : document.cookie
- .split(';')
- .find((p) => p.includes('impersonate='))
- ?.split('=')[1];
+ const authNonSecuredImpersonate =
+ typeof document === 'undefined'
+ ? null
+ : document.cookie
+ .split(';')
+ .find((p) => p.includes('impersonate='))
+ ?.split('=')[1];
const fetchRequest = await fetch(params.baseUrl + url, {
...(secured ? { credentials: 'include' } : {}),
@@ -43,6 +57,7 @@ export const customFetch = (
? {}
: { 'Content-Type': 'application/json' }),
Accept: 'application/json',
+ ...(loggedAuth ? { auth: loggedAuth } : {}),
...options?.headers,
...(auth
? { auth }