【发布时间】:2019-12-25 04:17:43
【问题描述】:
在我的通用 nuxt 应用程序中,我将代理设置为 true 并重写了我的 url 以避免 CORS 问题。 但是当我将代理设置为 true 时,我所有的发布请求都被更改为获取请求。不明白为什么以及如何配置它来进行这种转换。
这是我的 nuxt.config.js :
/*
** Axios module configuration
*/
axios: {
proxy: true
},
proxy: {
'/apicore/': { target: 'http://blablabla.fr', pathRewrite: { '^/apicore/': '' }, changeOrigin: true }
}
我的电话:
async createJoueur({ state, dispatch, commit }, data) {
const URL = '/apicore/joueur'
await this.$axios
.post(
URL,
data, {
headers: {
'Content-Type': 'application/json'
}
}
)
.then((response) => {
console.log('JOUEUR LOGGED : ')
if (response.status === 200) {
} else {
console.log('Login failed / Not found')
}
}
)
.catch((error) => {
console.log('ERROR')
})
将此代理设置为 true,我的 post-call 就变成了 get one。 我是否忘记了配置中的某些内容?
感谢您的帮助。
【问题讨论】:
-
您有没有偶然找到解决方案?我遇到了同样的问题...
-
同样的问题,想知道如何解决这个问题...@Bruno 的回答没有为我解决