2021年4月30日星期五

About proxy settings when sending requests to multiple servers

I personally develop apps with Nuxt.js.

I am using axios for API communication, and I am using proxy to avoid CROS restrictions, but I do not understand how to set proxy when sending requests to multiple servers.

I searched online, but I couldn't find an article that could be solved, so I asked a question here.

I tried to write the code myself, but it would be very helpful if you could give me some advice such as how to do it this way.

What you want to achieve

The database uses DynamoDB. I want to register the posted content in DynamoDB and get it from the database.

signUp(){        this.$axios.$get('/signUp',        {          m_users: {              user_name: this.username,              mailaddress: this.mailaddress,              password: this.password          }        })        .then(res => {          console.log(res);        });      },      async getList() {        await this.$axios.$get('/api')          .then(res => {              console.log(res);          });      }      async addPost() {        await this.$axios.post('/post',                  {                    t_items: {                        item_id: this.nextId,                        shop_name: this.shop,                        item_name: this.name,                        item_price: this.price,                        item_unit: this.unit,                        post_date: date                    }                  }        )        .then(res => {          console.log(res);        })  
 proxy: {      '/api': {        target: 'URL',        pathRewrite: {          '^/api': ''        }      },      '/signUp': {        target: 'URL',        pathRewrite: {          '^/api': ''        }      },      '/post': {        target: 'URL',        pathRewrite: {          '^/api': ''        }      }    },    axios: {      prefix: '/api',    },  

Is this correct?

https://stackoverflow.com/questions/67333720/about-proxy-settings-when-sending-requests-to-multiple-servers April 30, 2021 at 08:13PM

没有评论:

发表评论