[Vuejs]-Axios request from Vue app deployed on amazon S3 returns site's index

0👍

The webpack proxy that was defined

proxy: {
  // proxy all requests starting with /v1
  '/v1': {
    target: 'http://some-app-deployed-on.elasticbeanstalk.com/v1',
    changeOrigin: true,
    pathRewrite: {
      '^/v1': '',
    },
  },

Is only valid when running in a dev environment.

So all my requests where directed to localhost

axios
    .get(`/v1/endpoint/${param}`)
    .then((response) => {
      console.log(response);
    })

I either need to configure a redirection in S3 / cloudfront or configure webpack so that requests /v1/endpoint/${param} are changed into http://some-app-deployed-on.elasticbeanstalk.com/v1/endpoint/${param}

I’m happy to accept any answer that helps me implement the solutions above.

EDIT:

Impossible to make the S3 webapp communicate with the back on EB…
I moved everything in the same EB

0👍

I’m not sure you’re setting the parameters right.

Maybe something like this

  axios
    .get(`/v1/endpoint`, params: {
      param
    })
    .then((response) => {
      console.log(response);
    })

Or Even

  axios
    .get('/v1/endpoint/' + param)
    .then((response) => {
      console.log(response); 
  })

Leave a comment