首页 新闻 会员 周边 捐助

从 angular 15 升级到 angular 19 后 HttpInterceptor 的实现不起作用

0
悬赏园豆:30 [已解决问题] 解决于 2025-05-18 22:45

应用中实现了2个 HttpInterceptor,升级到 angular 19 后都没有被执行

export class XsrfInterceptor implements HttpInterceptor { 
    // ...
}
export class AuthErrorResponseInterceptor implements HttpInterceptor {
    // ...
}

请问如何解决这个问题?

dudu的主页 dudu | 高人七级 | 园豆:25263
提问于:2025-05-18 22:05
< >
分享
最佳答案
0

需要在 app.config.js 中,给 provideHttpClient 加上 withInterceptorsFromDi

provideHttpClient(withFetch(), withInterceptorsFromDi())
dudu | 高人七级 |园豆:25263 | 2025-05-18 22:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册