cb пре 1 месец
родитељ
комит
dd64aa9002
1 измењених фајлова са 7 додато и 3 уклоњено
  1. 7 3
      src/app/enterprise-trial.component.ts

+ 7 - 3
src/app/enterprise-trial.component.ts

@@ -499,15 +499,19 @@ export class EnterpriseTrialComponent implements OnInit, OnDestroy {
   }
 
   private async authJson(path: string, method: 'GET' | 'POST', body?: unknown): Promise<any> {
+    // 后端 /enterprise/* 通过 body.sessionToken 鉴权
+    // (enterprise-service.sessionUserFromRequest 优先读 req.body.sessionToken),
+    // 因此无需在 header 重复携带 Authorization / X-Parse-Session-Token。
     const headers: Record<string, string> = {
-      'Content-Type': 'application/json',
-      'Authorization': `Bearer ${this.sessionToken}`,
-      'X-Parse-Session-Token': this.sessionToken
+      'Content-Type': 'application/json'
     };
     const response = await fetch(`${API_BASE}${path}`, {
       method,
       headers,
       cache: 'no-store',
+      // 明确不带 cookie/凭据:接口使用 body 的 sessionToken 鉴权;
+      // 若携带 credentials: "include",服务端返回 Access-Control-Allow-Origin: * 会被浏览器拦截(CORS 跨域报错)。
+      credentials: 'omit',
       body: method === 'GET' ? undefined : JSON.stringify({ ...(body || {}), sessionToken: this.sessionToken })
     });
     const result = await response.json().catch(() => ({}));