[Vuejs]-404 errors on static assets in Django/Vue app

0👍

As I can see from implementation in github, you need to define asset directory in your project like this(copy pasted from the code):

module.exports = {
    outputDir: 'dist',
    assetsDir: 'static',
    // baseUrl: IS_PRODUCTION
    // ? 'http://cdn123.com'
    // : '/',
    // For Production, replace set baseUrl to CDN
    // And set the CDN origin to `yourdomain.com/static`
    // Whitenoise will serve once to CDN which will then cache
    // and distribute
    devServer: {
      proxy: {
        '/api*': {
          // Forward frontend dev server request for /api to django dev server
          target: 'http://localhost:8000/',
        }
      }
    }
}

Basically what is happening here is that, your static files are being serverd in root path /, but static files should be served in path /static (ie: <your server>/static/js/abc.js)

👤ruddra

Leave a comment