Why is vue failing to set my proxy for api routes?

Viewed 23

I have a vue app I'm trying to connect to a flask api, all running on different ports on the same machine. My vue.config.js looks like this:

module.exports = {
    // options...
    devServer: {
        public: 'localhost',
        disableHostCheck: true,
        proxy: {
            '^/flask': {
                target: 'http://localhost:8001',
                pathRewrite: {'^/flask': '/'},
                changeOrigin: true,
                logLevel: "debug",
            },
            '/V2': {
                target: 'http://localhost:8001',
                changeOrigin: true,
                pathRewrite: {'^/V2': ''}
            },
        }
    }
}

where port 8001 is the port the flask is running on. Except the actual api requests from vue are being sent to port 9600 (and failing). For example:

fetchData() {
      const path = '/flask/search';
      console.log('Homepage recieved query')
      if (this.queryform !== 'initVal') {
        axios.post(path, this.queryform)
          .then((res) => {
            this.queryResult = res.data;
            console.log('Homepage recieved results');
          })
          .catch((error) => {
            console.log(error);
          });
      }
    },

results in the error "Proxy error: Could not proxy request //search from ****:8002 to http://localhost:9600 (ECONNREFUSED)." *** is the ip address, omitting for privacy sake.

I know this an error within vue, I'm able to successfully use all the api routes on the flask app using my api testing program.

I can't find anywhere in the code where requests are sent to :9600, is there another configuration file I need to change?

0 Answers
Related