[Vuejs]-Configure webpack proxy for http requests in VueJs + Axios

0👍

There’s nothing wrong with your proxyTable configuration per se. But…

Double check your config/index.js file. If you added that proxyTable snippet to the a config file with the default content, your config/index.js file will be:

module.exports = {
  dev: {
    proxyTable: {                                          // the snippet you added
      '/api': {                                            // the snippet you added
        target: 'http://jsonplaceholder.typicode.com',     // the snippet you added
        secure: false,                                     // the snippet you added
        changeOrigin: true,                                // the snippet you added
        pathRewrite: { '^/api': '' }                       // the snippet you added
      }                                                    // the snippet you added
    },                                                     // the snippet you added

    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},                  // <================================ oops...

    // Various Dev Server settings
    host: 'localhost', // can be overwritten by process.env.HOST
    ...

Now, notice there is a proxyTable: {}, property there. It is overwriting your configuration.

Solution: Remove proxyTable: {},.

Leave a comment