[英]axios.post works in chrome but not in firefox
Hello Everybody! 大家好!
I have a SPA made with vuejs, and also using webpack. 我有一个用vuejs制作的SPA,也使用webpack。 To make http calls, i am using axios, but something really strange is happening ...
为了拨打http电话,我正在使用axios,但是确实发生了一些奇怪的事情...
When i use the spa on CHROME everything works fine, but ANY other browser (safari, firefox, iosSafari) gives me the following error: 当我在CHROME上使用spa时,一切正常,但是任何其他浏览器(safari,firefox,iosSafari)给我以下错误:
Error: Network Error
Stack trace:
createError@webpack-internal:///34:16:15
handleError@webpack-internal:///33:88:14
Error shown in console (more details) 控制台中显示错误(更多详细信息)
The code that makes this call is: 进行此调用的代码是:
const rep = localStorage.getItem('rep')
const token = localStorage.getItem('token')
const config = {
headers: {
'Content-Type': 'application/json',
'x-access-token': token
}
}
axios.post('localhost:1234/statusproducao', { representante: rep }, config)
.then((response) => {
Loading.hide()
this.statusPinos = response.data.statusProducao
})
.catch((error) => {
Loading.hide()
console.log(error)
})
Looking at devtools --> network, i can see that the browser didn't make the post request, and the error shown before, comes from the .catch(error) from axios.post 查看devtools->网络,我可以看到浏览器没有发出发布请求,并且之前显示的错误来自axios.post的.catch(error)。
The const rep, and token are both strings. const rep和token都是字符串。
What am i missing ? 我想念什么?
I added the 'x-access-token' header on my cors, and in the routes, i needed this too: 我在cors上添加了“ x-access-token”标头,在路由中,我也需要这样做:
'x-access-token': token 'x-access-token':令牌
server.opts(/\.*/, function (req, res, next) {
res.send(200)
next()
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.