Ninja Framework 中是否有特定的预检方式?
我正在尝试允许所有预检请求,但是由于我没有使用 options 方法的所有内容的路由,它出现为 404 并且失败。
本质上,我收到了这个错误并试图摆脱它:
Access to XMLHttpRequest at 'https://example.com/path/to/endpoint' from origin 'http://localhost:8080' 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.
有没有办法捕获所有选项方法并允许它们?而不是用选项请求重写每条路线?
即代替:
router.GET().route("/index.html").with(ApplicationController::index);
router.OPTIONS().route("/index.html").with(ApplicationController::index);
router.GET().route("/user").with(ApplicationController::user);
router.OPTIONS().route("/user").with(ApplicationController::user);
相反,它会是这样的(下面的伪代码):
router.OPTIONS().route(<All Routes>).respond("200 OK");