Auth0 Home Blog Docs

HttpInterceptor not always called

Hi,

I followed the tutorial on SPA app (using Angular 8) and for some reason it is not allways calling properly the interceptor.

There are two endpoints on my API server, in particular, when I make a POST request to /api/door (to create a new door), it doesn’t add the token, but when I make a GET request to /api/door/all to get all the doors, it does.

When looking at the different requests in background, I noticed that for that POST request to /api/door, an OPTIONS one is fired with only “Access-Control-Request-Headers: content-type”, when all the other POST request for which the token is properly added, the OPTIONS one has “Access-Control-Request-Headers: authorization,content-type”.

Any body would have an idea why ? I don’t remember making any configuration on what request should or should not require Authorization Token. I did not implement any filter on the HttpInterceptor also.

Thanks in advance for your help.

1 Like

Welcome to Auth0 community @gpfister

Could you post your src/app/app-routing.module.ts and src/app/interceptor.service.ts code snippets here? It is possible that POST /api/door call is not protected

I’m sorry, I figure it out last nigh (too laye to remember closing this thread). The issue was in my code, with a service incorrectly provided, that mess up the interceptors.

1 Like

No worries, thanks for letting us know. Glad you solved it @gpfister

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.