POST请求之前额外的GET请求,我的代码不是 [英] Additional GET requests before POST request that my code isn't making

查看:98
本文介绍了POST请求之前额外的GET请求,我的代码不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有在生产环境中,绝对不能在本地主机上运行,​​superagent似乎在POST请求之前发出额外的GET请求。这与这个未解答的问题类似,不过那是使用其他软件,这是简单的superagent。



客户端代码很简单的一个POST请求:

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

$ b $这是交叉源请求共享。



其他GET请求是CORS'飞行前'请求。这是固定在节点/快递应用程序使用:

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


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)
})

解决方案

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());

这篇关于POST请求之前额外的GET请求,我的代码不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆