feat(frontend): added fix for base url in api side

This commit is contained in:
Amit Ranjan 2024-10-01 19:17:54 +05:30
parent 2871fb432c
commit 008257db64

View File

@ -1,6 +1,10 @@
export const buildURL = (baseUrl: string, relativePath: string): string => {
try {
const url = new URL(relativePath, baseUrl);
const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
const normalizedRelativePath = relativePath.startsWith('/')
? relativePath.slice(1)
: relativePath;
const url = new URL(normalizedRelativePath, normalizedBaseUrl);
return url.toString();
} catch {