Additional GET requests before POST request that m

2019-09-09 16:28发布

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条回答
乱世女痞
2楼-- · 2019-09-09 17:05

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());
查看更多
登录 后发表回答