1

My code and question are exactly This.

But I am getting the error like

Access to XMLHttpRequest at 'http://localhost:8080/api/v1/basicauth' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
zone-evergreen.js:2828 

GET http://localhost:8080/api/v1/basicauth net::ERR_FAILED

I have followed the same instruction in the accepted answer still I am getting the same error.

I have added the doFilter method in my SpringSecurityConfig class. Still, I am getting the same error. I am getting the below error in the network.

http://localhost:8080/api/v1/basicauth if I hit this URL I am getting 404 error

from eclipse I am running debug mode, it is not showing any debug point enables, what might be the issue.

enter image description here Can you help me fix and understand that kind of problem? Thanks! :)

Sohail Ahmad
  • 7,309
  • 5
  • 27
  • 46
Code Lღver
  • 175
  • 1
  • 4
  • 16
  • OK, what happens when you open http://localhost:8080/api/v1/basicauth directly in your browser? – sideshowbarker Feb 10 '20 at 06:30
  • I am getting 404 error – Code Lღver Feb 10 '20 at 06:31
  • 2
    OK, yeah — so you don’t actually have a CORS problem. Instead you have a 404 problem. If you fix the 404 problem, then I expect you’re gonna find that your existing CORS config is already working as expected. You’re seeing that CORS message only because most servers by default don’t add the Access-Control-Allow-Origin response header to 4xx errors. – sideshowbarker Feb 10 '20 at 06:34

0 Answers0