简体   繁体   English

Angular拦截器302响应

[英]Angular interceptor 302 response

I am adding a http interceptor in an existing Angular 11 app.我在现有的 Angular 11 应用程序中添加了 http 拦截器。

We have 2 resquests onload, they work as expected but when I add the interceptor with no logic, just return the same request, one request starts throwing 302 found status.我们有 2 个请求加载,它们按预期工作,但是当我添加没有逻辑的拦截器时,只返回相同的请求,一个请求开始抛出 302 found 状态。

So, I dont understand how I should fix this or if there is a walk-around.所以,我不明白我应该如何解决这个问题,或者是否有一个走动。

Thanks for your help谢谢你的帮助

import { Injectable } from '@angular/core'; import { HttpInterceptor, HttpEvent, HttpResponse, HttpRequest, HttpHandler } from '@angular/common/http'; import { Observable } from 'rxjs';

@Injectable() export class MyInterceptor implements HttpInterceptor {  intercept(httpRequest: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    return next.handle(httpRequest);   } }

I think you missed something.我想你错过了什么。 Please view carefully this article and then check.请仔细阅读这篇文章,然后检查。 I hope this will work for you https://ultimatecourses.com/blog/intro-to-angular-http-interceptors我希望这对你有用 https://ultimatecourses.com/blog/intro-to-angular-http-interceptors

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM