main.ts 829 B

12345678910111213141516171819
  1. import { bootstrapApplication } from '@angular/platform-browser';
  2. import { appConfig } from './app/app.config';
  3. import { App } from './app/app';
  4. import { PlatformProxyService } from './app/core/api/platform-proxy.service';
  5. /*
  6. * 🔴 启动前先探测平台代理(CORS 兼容层,见 `platform-proxy.service.ts`)。
  7. *
  8. * 平台 `/api/**` 的响应偶尔带两行 `Access-Control-Allow-Origin`,浏览器直接拦掉
  9. * 登录与全部云函数调用。探测到 `/api-platform/**` 可用就统一走同源代理,
  10. * 探不到(代理未部署)就原样直连 —— **探测失败不影响启动**。
  11. */
  12. const proxy = new PlatformProxyService();
  13. const ready = proxy.probe().catch(() => false);
  14. ready
  15. .catch(() => false)
  16. .then(() => bootstrapApplication(App, appConfig))
  17. .catch((err) => console.error(err));