origin ‘http://localhost:4200’ has been blocked by CORS policy in Angular7

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 *.mydomain.example then you can edit your hosts file and add 127.0.0.1 local.mydomain.example in there, then in your browser instead of localhost:4200 enter local.mydomain.example:4200

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)