origin 'http://localhost:4200' has been blocked by CORS policy in Angular12

 Solution 1 - you need to change your backend to accept your incoming requests

Solution 2 - using Angular proxy see here

Please note this is only for ng serve, you can't use proxy in ng build

Solution 3 - IF your backend accepts requests from a wildcard domanin like *.testdomain.example then you can edit your hosts file and add 127.0.0.1 local.testdomain.example in there, then in your browser instead of localhost:4200 enter local.testdomain.example:4200

Note: the reason it's working via postman is postman doesn't send preflight requests while your browser does.

No comments:

Post a Comment

CPU vs GPU Architecture

  CPU vs GPU Architecture CPU (Central Processing Unit) and GPU (Graphics Processing Unit) have distinct architectural differences, optimize...

Best for you