我意识到我不完全理解Express是如何处理“preflight OPTIONS请求”的,这是一个标准设置:
const cors = require('cors');
const app = express();
app.use(cors({
preflightContinue: true // here
}));
我有两个问题:
preflightContinue: true
和preflightContinue: false
有什么区别
1.哪个是默认的快速设置?- 我猜标志默认为false
1.最重要的是:对于preflightContinue: true
,* 何时/如何 * 响应OPTIONS请求?它是否会神奇地响应正常的请求?
1条答案
按热度按时间cetgtptt1#
此选项允许您在设置了必要的头之后,使用自己的中间件来制造对preflight请求的响应。参见源代码。
一个(完全人为的)例子是在preflight响应中设置一个非标准的header,如下所示:
需要此选项的更好理由可以在https://github.com/expressjs/cors/issues/305#issuecomment-1761041281中找到。