'How to implement a single instance of httpinterceptors throughout multiple applications using single-spa.js
I am using the single-spa.js library to make multiple angular apps in the same system. Right now, i am using an httpInterceptor for every app with a code like this in app.module of each
@NgModule({
declarations: [
// etc..
],
imports: [
BrowserModule,
HttpClientModule,
StoreModule.forRoot(reducers, {
metaReducers,
}),
!environment.production ? StoreDevtoolsModule.instrument() : [],
// etc...
],
bootstrap: [
AppComponent
],
providers: [httpInterceptorProviders, DataService, FuseSplashScreenService, WindowRefService,
AuthGuardService,
AppInitService]
})
export class AppModule {
}
The interceptors work correctly as expected but having multiple interceptors is causing problems with thread safety on them and causing the token to be mixed up between requests (the interceptor from 1 application used the token from localstorage and sent a request to server, when the interceptor from app 2 used the same token before the response for the first app updated the token in localstorage. ) .. resulting in an "invalid token" server response from app2 request.
my question is, is there a way to have one http interceptor across multiple applications in my project?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
