[Vuejs]-Vue-resource and http-proxy-middleware not routing to backend

2👍

Your setup looks good and the requests should look like they’re coming from 8080 since it is a proxy.

Are you sure something should be returning where you’re looking? I have literally the same setup and it works.

My guess is since http://localhost:8080/api can’t be found either can http://localhost:3000 since they’re the same thing.

If that doesn’t solve your problem you can dig a little deeper and debug and see if anything looks funny there.

proxyTable: {
  '/api': {
    target: 'http://localhost:3000',
    changeOrigin: true,
    logLevel: 'debug',
    pathRewrite: {
      '^/api': '',
    },
  },
},

Here goes a shot of everything working with my stuff:

enter image description here

0👍

what worked for me was setting up a vue.config.js file on the root dir of the vue project (that is at the same level that pacakge.json) and within that file I used this code:

module.exports = {
  devServer: {
    proxy: {
      "^/api": {
        target: "http://localhost:3000",
        ws: true,
        changeOrigin: true
      }
    }
  }
}

now that the proxy was setup in the vue app the request would reach my express server 😀

Leave a comment