HttpInterceptors 的顺序

Order of HttpInterceptors

我有一个使用注册 HttpInterceptor 的插件的应用程序。

现在我需要创建自己的拦截器,它需要 运行 另一个拦截器之前,因为它会改变 localStorage 中另一个拦截器的一些值使用。

注册新的 HttpInterceptor 时如何影响执行顺序?

您不能设置拦截器顺序。拦截器按照它们被声明的顺序链接起来。

您将编写自己的超级拦截器,允许使用一些排序逻辑附加子拦截器。

https://angular.io/guide/http#interceptor-order

Angular applies interceptors in the order that you provide them. If you provide interceptors A, then B, then C, requests flow in A->B->C and responses flow out C->B->A.