[Vuejs]-Django + Vue.js GET /ws HTTP/1.1 404 2292 error every second

0👍

I found the solution to a similar way as Thomas. It seems that the default behavior of setting a proxy in vue.config.js is to send a GET request to /ws. I had to change the /ws in Thomas’s answer to /api since that is what the back-end uses for their routes, so I ended up with this:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    proxy: {
      '^/api': {
        target: 'http://localhost:8000'
      }
    }
  }
})

0👍

In your proxy config, you probably want something like this:

      '^/ws': {
          target: 'localhost:8080',
      },

… basically, don’t proxy the /ws path, send those requests to the devserver. Or maybe there is a common prefix for your django endpoints you can use to qualify paths that should be proxied.

Leave a comment