IONIC 3 CORS ISSUE

后端 未结 7 2387
小蘑菇
小蘑菇 2020-12-09 18:16

I am having a CORS issue with Ionic 3 when attempting to make GET calls to an API. I am using Ionic local server, running ionic serve in the command line for li

7条回答
  •  庸人自扰
    2020-12-09 18:46


    ```
    export function getAuthHttp(http: Http, options: RequestOptions) {
      console.log("token",storage.get('id_token'));
      return new AuthHttp(new AuthConfig({
              headerName: 'Authorization',
              headerPrefix: 'bearer',          
              tokenName: 'id_token',
              tokenGetter: (() => storage.get('id_token')),
              noJwtError: true,    
              //globalHeaders: [{'Accept': 'application/json'}],
              globalHeaders: [{'Content-Type':'application/json'},{"Access-Control-Allow-Origin": "*"}],
             
            }), http, options);
    }
    ```
    

提交回复
热议问题