I'm new to Angular and trying to use HTTP interceptor here.
I just wonder whether should I lump multiple interceptors, like setting headers' token, cache-control, content-type in one file, or should I separate it into token.interceptor.ts for token and put other general headers in headers.interceptor.ts.
Does the later have worse performance since it have to call req.clone() one more time just to set headers, or does Angular injection works the other way? Which is the best practice regarding this topic?
Thanks for your opinion.
We can divide this question into 2 sub-questions.
You can set multiple headers in angular httpInterceptor. It does support multiheader functionality.
If you must alter a request, clone it first and modify the clone before passing it to next.handle().The clone() method's hash argument allows you to mutate specific properties of the request while copying the others. Refer API documentation