CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true

后端 未结 9 2527
借酒劲吻你
借酒劲吻你 2020-11-22 01:54

I have a setup involving

Frontend server (Node.js, domain: localhost:3000) <---> Backend (Django, Ajax, domain: localhost:8000)

Browser <-- webapp <

9条回答
  •  失恋的感觉
    2020-11-22 02:54

    Had this problem with angular, using an auth interceptor to edit the header, before the request gets executed. We used an api-token for authentification, so i had credentials enabled. now, it seems it is not neccessary/allowed anymore

    @Injectable()
    export class AuthInterceptor implements HttpInterceptor {
      intercept(req: HttpRequest, next: HttpHandler): Observable> {
        req = req.clone({
          //withCredentials: true, //not needed anymore
          setHeaders: {
            'Content-Type' : 'application/json',
            'API-TOKEN' : 'xxx'
          },
        });
        
        return next.handle(req);
      }
    

    Besides that, there is no side effects right now.

提交回复
热议问题