[Vuejs]-Configure NGINX to redirect '/' location to static site hosted on S3

0👍

Something like this should do the trick:

location / {
     try_files $uri.html /path_to_the_static_hosted_site/index.html =404;
    }

Do not forget:

  • The path_to_the_static…. should be relative of the root of your project. Eg. If your static_file is inside public/static/index.html and the root in you nginx config is /home/usr/sitename.xyz/public, the path will be /static/index.html

  • On vue, you should set inside the vue.config.js file, the publicPath, to tell Babel where to look for files to dynamic import: eg.

    module.exports = { publicPath: '/static/dist'...

Leave a comment