Skip to content

Commit dd1a547

Browse files
feat: Add dynamic hotel-id injection [CHECK IF WORKS LOCALLY] (#332)
* feat: Add dynamic hotel-id injection * refactor: Remove duplicate /api/v1 appending * feat: Remove /api/v1 guards
1 parent 4f23fe9 commit dd1a547

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

clients/shared/src/api/client.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export const createRequest = (
88
getToken: () => Promise<string | null>,
99
baseUrl: string,
1010
) => {
11-
const hardCodedHotelId = "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"
1211
return async <T>(config: RequestConfig): Promise<T> => {
12+
const hotelId = getConfig().hotelId;
1313
let fullUrl = `${baseUrl}${config.url}`;
1414
if (config.params && Object.keys(config.params).length > 0) {
1515
const searchParams = new URLSearchParams(config.params);
16-
fullUrl += '?' + searchParams.toString();
16+
fullUrl += "?" + searchParams.toString();
1717
}
1818

1919
try {
@@ -24,7 +24,7 @@ export const createRequest = (
2424
headers: {
2525
"Content-Type": "application/json",
2626
...(token && { Authorization: `Bearer ${token}` }),
27-
"X-Hotel-ID": hardCodedHotelId,
27+
"X-Hotel-ID": hotelId,
2828
...config.headers,
2929
},
3030
body: config.data ? JSON.stringify(config.data) : undefined,
@@ -100,10 +100,5 @@ export const getBaseUrl = (): string => {
100100
throw new Error("API_BASE_URL is not configured. Check your .env file.");
101101
}
102102

103-
const trimmed = url.replace(/\/+$/, "");
104-
if (trimmed.endsWith("/api/v1")) {
105-
return trimmed;
106-
}
107-
108-
return `${trimmed}/api/v1`;
103+
return url;
109104
};

0 commit comments

Comments
 (0)