2023-09-12 18:51:02 +00:00
|
|
|
import { getClientConfig } from "../config/client";
|
2024-02-07 05:17:11 +00:00
|
|
|
import { ApiPath, DEFAULT_API_HOST } from "../constant";
|
2023-09-12 18:51:02 +00:00
|
|
|
|
|
|
|
export function corsPath(path: string) {
|
2024-02-07 05:17:11 +00:00
|
|
|
const baseUrl = getClientConfig()?.isApp ? `${DEFAULT_API_HOST}` : "";
|
2023-09-12 18:51:02 +00:00
|
|
|
|
2024-03-13 19:03:46 +00:00
|
|
|
if (baseUrl === "" && path === "") {
|
|
|
|
return "";
|
|
|
|
}
|
2023-09-12 18:51:02 +00:00
|
|
|
if (!path.startsWith("/")) {
|
|
|
|
path = "/" + path;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!path.endsWith("/")) {
|
|
|
|
path += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
return `${baseUrl}${path}`;
|
|
|
|
}
|