我有我的网站和我的api托管在同一个端口上的服务器(:80)。 我想从我的网站视图发送请求到我的api。没有'Access-Control-Allow-Origin'标题出现在请求的资源API和网站在同一端口
这是我的要求:(我reactJS拼命地跑它componentWillMount)
axios.request({
url: ROOT_URL + '/user/comfirmation/' + tmp[1],
method: 'get',
data: null,
headers: {
'Content-Type': 'application/json'
}
})
.then((response) => {
if (response.data.Type == "EmailUpdated") {
this.setState({
actualState: 'success',
type: response.data.Type,
email: response.data.Email
})
} else {
this.setState({
actualState: 'success',
type: response.data.Type
})
}
}).catch((error) => {
this.setState({
actualState: 'error'
})
})
它完美的地方,但在我的网站上部署我得到这个错误:
但方法是允许的:
我试过取回我没有这个错误,但我真的想解决与axios这个问题,因为我更喜欢它的实现。有人能帮我吗?
你的ROOT_URL是什么? – bitten
您使用的是IIS吗?如果是这样的版本? –
这看起来不太正确:''Content-Type':'Content-Type':'application/json'' –