add workspace navbar status + creation modal
This commit is contained in:
@@ -2,7 +2,6 @@ import { API_BASE_URL } from "../config/constants";
|
||||
|
||||
export const authFetch = async (endpoint: string, options: RequestInit = {}) => {
|
||||
const token = localStorage.getItem("accessToken");
|
||||
|
||||
const isFormData = options.body instanceof FormData;
|
||||
|
||||
const headers: HeadersInit = {
|
||||
@@ -11,7 +10,12 @@ export const authFetch = async (endpoint: string, options: RequestInit = {}) =>
|
||||
...options.headers,
|
||||
};
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
||||
// Safely join URLs preventing double slashes (e.g., "http://api.com//api/..." -> "http://api.com/api/...")
|
||||
const cleanBaseUrl = API_BASE_URL.replace(/\/+$/, "");
|
||||
const cleanEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
|
||||
const url = `${cleanBaseUrl}${cleanEndpoint}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user