Additional GET requests before POST request that my code isn't making

痴心易碎 提交于 2019-12-13 04:50:01

问题


Only in production, and never on localhost, superagent seems to made additional GET request right before POST requests. This is similar to this unanswered question however that was using other software, this is simply superagent.

The client code is simple a POST request:

superagent
.post('/api/v1/csr/whois')
.send({
    someKey: someValue
})
.end(function(res){
    log('Whois response:', res)
})

回答1:


This is Cross Origin Request Sharing.

The additional GET requests are CORS 'pre-flight' requests. This was fixed in node/express app using:

var cors = require('cors');
app.use(cors());


来源:https://stackoverflow.com/questions/33080529/additional-get-requests-before-post-request-that-my-code-isnt-making

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!