HTTP interceptor getting status 0 on failed request using Angular 2,4,6,7,8,9 TypeScript

前端 未结 2 522
情话喂你
情话喂你 2020-12-19 14:41

I have following implementation of HTTP interceptors with Angular ^4.3.6.

import {Injectable} from \"@angular/core\";
import {
  HttpInterceptor         


        
2条回答
  •  既然无缘
    2020-12-19 15:21

    I found out what was causing the issue.. Its a server side issue. You need to set the CORS middleware first then the remaining API middlewares.

    Please note i am working with Laravel 5.6 + Angular 5

    Wrong Code

    'api' => [
                'throttle:60,1',
                'bindings',
                \Barryvdh\Cors\HandleCors::class,
            ],
    

    Currect Code

    'api' => [
                \Barryvdh\Cors\HandleCors::class,
                'throttle:60,1',
                'bindings'
            ],
    

提交回复
热议问题