I know that responses are http 302handled directly by the browser, and because of this, you cannot get any of the request properties from the source code. But I am wondering if there is a way to intercept the 302 redirect response. Let me explain:
- My Frontend (Angular) makes an HTTP request A (I intercept the outgoing request)
- A answers
302 Location: B - My Frontend intercepts a response
302with empty fields and goes to B - Here I would like to intercept the answer coming from B
This is my Angular interceptor http code:
@Injectable()
export class CasInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log('->Interceptor');
console.log(req);
return next.handle(req).map((event: HttpEvent<any>) => {
const response = event as HttpResponseBase;
console.log('<-Interceptor');
console.log(response);
return event;
});
}
}
source
share