I have come across a situation where I make a call from my angular 6 application to my spring boot application. When I call an HTTP post method in angular to the application running on a different port it throws an exception.
Access to XMLHttpRequest at 'http://localhost:8080/api' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
My Angular application Running on 'http://localhost:4200' port number:4200
My Spring Boot application running on 'http://localhost:8080/api': port number:8080.
There is no direct answer to solve this problem. There are few hacks to disable the security in chrome and using NGINX you can resolve this issue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…