当代理设置为true时,Nuxt代理将POST更改为GET

问题描述 投票:0回答:1

在我的通用nuxt应用程序中,我已将proxy设置为true,并重新写了我的URL以避免CORS问题。但是,当我将proxy设置为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时,我的帖子通话变成了获得一通。我是否忘记了配置中的某些内容?

感谢您的帮助。

proxy axios nuxt
1个回答
0
投票

我遇到了同样的问题!我使用changeOrigin解决了:错误。

我知道它必须是默认值(Look at changeOrigin session),

但是在nuxtjs代理实现中,该值默认为true(Look at Options session)。

© www.soinside.com 2019 - 2024. All rights reserved.