main #1

Merged
Brook-Tewabe-Yaltopia merged 2 commits from main into prod 2026-04-17 11:44:52 +03:00
2 changed files with 3 additions and 6 deletions
Showing only changes of commit 4386b6100e - Show all commits

View File

@ -1,6 +1,5 @@
import { parseApiError } from '@/lib/auth-api';
const API_PREFIX = '/api';
function getBaseUrl(): string {
return import.meta.env.VITE_API_BASE_URL ?? '';
@ -56,7 +55,7 @@ async function request(
if (body !== undefined && !isFormData) headers["Content-Type"] = "application/json";
if (token) headers.Authorization = `Bearer ${token}`;
const url = `${getBaseUrl()}${API_PREFIX}${resolved}`;
const url = `${getBaseUrl()}${resolved}`;
return fetch(url, {
...init,
method,
@ -103,7 +102,7 @@ export async function apiDownloadBlob(
const headers: Record<string, string> = { ...(init?.headers as Record<string, string>) };
if (token) headers.Authorization = `Bearer ${token}`;
const url = `${getBaseUrl()}${API_PREFIX}${resolved}`;
const url = `${getBaseUrl()}${resolved}`;
const res = await fetch(url, { ...init, method: 'GET', headers });
if (!res.ok) throw new Error(await parseApiError(res));

View File

@ -1,7 +1,5 @@
import type { RegisterHotelStaffDto, StaffAccess } from "@/lib/types";
const API_ROOT = "/api";
let getPropertyId: () => string | null = () => null;
/** Register property scope for hotel auth-API paths (e.g. staff management). */
@ -31,7 +29,7 @@ function rewriteHotelPath(path: string): string {
function apiUrl(path: string): string {
const base = import.meta.env.VITE_API_BASE_URL ?? "";
const resolved = rewriteHotelPath(path);
return `${base}${API_ROOT}${resolved}`;
return `${base}${resolved}`;
}
export async function parseApiError(res: Response): Promise<string> {