refinement phase 4
This commit is contained in:
@@ -36,9 +36,13 @@ export async function clientFetch<T>(path: string, options?: RequestInit, isRetr
|
||||
const locale = window.location.pathname.split('/')[1] || 'fa';
|
||||
|
||||
const reqHeaders: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept-Language': locale,
|
||||
};
|
||||
// Let the browser set `Content-Type` (with the multipart boundary) for FormData bodies — a manual
|
||||
// JSON content-type there breaks the upload. JSON bodies still declare it explicitly.
|
||||
if (!(options?.body instanceof FormData)) {
|
||||
reqHeaders['Content-Type'] = 'application/json';
|
||||
}
|
||||
if (token) {
|
||||
reqHeaders['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user