Despite checking numerous sources online, I am facing a persistent issue with my Angular application. The problem arises when using HttpClient along with an Angular interceptor to set headers for authentication in my Java Rest API using JWT tokens. The interceptor seems to malfunction, resulting in the Java side receiving a null token and generating errors. Any assistance would be highly appreciated.
Upon closer inspection, it appears that the root of the issue lies within Spring Security. After debugging, it was revealed that the options request all filter lacks the necessary header, ultimately causing token-related exceptions. Potentially allowing bypass for option method requests could resolve the problem.
Snippet of the Spring Boot Security Configuration:
(Security Config code here)
Code snippet of the Angular Interceptor:
(Angular Interceptor code here)
Code snippet of the Angular Service:
(Angular Service code here)
Method Call:
(Method call code here)
Browser Network Results:
https://i.sstatic.net/Dvx61.png
Local Storage for Token:
https://i.sstatic.net/vGuus.png
Error Message in Browser Console:
https://i.sstatic.net/K7Drm.png
Error Message from Spring Boot Java Console: