I have an application with several services and plugins that use the HttpClient from @aurelia/fetch-client.
I would like to add a configuration to the fetch-client globally, a baseUrl and some interceptors.
How can I override the HttpClient settings globally?
In v1 I could do something like this within the aurelia configuration function:
let http = new HttpClient();
http.configure(configure => {
configure
.withBaseUrl('')
.withHeader("X-CSRFToken", getCookie("csrftoken"))
.withHeader('Accept', 'application/json')
.withHeader('Content-Type', 'application/json')
.withInterceptor({
request: (request) => {
return request;
},
response: (response) => {
return response;
}
})
});
aurelia.container.registerInstance(HttpClient, http);
in v2 there does not seem to be a way to do this with the fetch-client.