被 CORS 策略 Angular 和 Slim 阻止

Blocked By CORS Policy Angular and Slim

我在前面是 运行 angular 应用程序,在后端是苗条的,但是当在浏览器中点击 api url 时它不起作用但在邮递员中它工作正常谢谢!

备注

i have followed every related posts out there in stack overflow but still i did not get any solution

Access to XMLHttpRequest at 'http://school_erp_api.dev/login' from 
origin 'http://localhost:4200' has been blocked by CORS policy: 
Response to preflight request doesn't pass access control check: 
Redirect is not allowed for a preflight request.

简单地说,您的后端需要响应 Allow-Origin header 以便您的预检(OPTIONS 请求)通过并且服务器允许 CORS。所以,你的后端应该发送 Access-Control-Allow-Origin: <domain>, ... | *

有关使用 slim 实现此功能的方法,请查看 here