-
-
Notifications
You must be signed in to change notification settings - Fork 593
Description
Current behavior
At the moment, the loader uses HttpClient internally (or HttpBackend - which is a current solution, but feels a bit hacky and non-standard and is less flexible).
The recommended way to be able to control Http Interceptors is by using HttpContext. So for httpClient requests, you can pass a context which looks like:
this.http.get(URL, {context: new HttpContext().set(SKIP_AUTH_TOKEN, true)})
where SKIP_AUTH_TOKEN is an HttpContextToken you can make yourself.
in your interceptor you can use this context to make decisions (in this example to skip auth, but you can use it for other things as well):
if (req.context.get(SKIP_AUTH_TOKEN)) {
// Should not attach a token to this request, return request early
return next(req);
}
Expected behavior
It would be great to allow a context to be passed to the provideTranslateHttpLoader for ultimate flexibility. The useHttpBackend mighjt no longer be needed then. So like this:
provideTranslateService({
loader: provideTranslateHttpLoader({
prefix: '/i18n/',
suffix: '.json',
context: new HttpContext().set(SKIP_AUTH_TOKEN, true)
}),
fallbackLang: 'nl',
}),
What is the motivation / use case for changing the behavior?
More flexible and more standardized solution to configure Injectors with the loader.