【发布时间】:2019-12-19 11:17:33
【问题描述】:
在 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");
【问题讨论】:
标签: java ninjaframework