cors.ts 425 B

12345678910111213141516171819
  1. import { getClientConfig } from "../config/client";
  2. import { ApiPath, DEFAULT_API_HOST } from "../constant";
  3. export function corsPath(path: string) {
  4. const baseUrl = getClientConfig()?.isApp ? `${DEFAULT_API_HOST}` : "";
  5. if (baseUrl === "" && path === "") {
  6. return "";
  7. }
  8. if (!path.startsWith("/")) {
  9. path = "/" + path;
  10. }
  11. if (!path.endsWith("/")) {
  12. path += "/";
  13. }
  14. return `${baseUrl}${path}`;
  15. }