9951 explained code solutions for 126 technologies


vue.jsHow can I configure Vue.js to use Nginx?


To configure Vue.js to use Nginx, you need to do the following:

  1. Create a Nginx configuration file vue-project.conf with the following contents:
server {
    listen       80;
    server_name  localhost;

    # Vue.js root directory
    root         /www/vue-project;

    # Serve static files
    location / {
        try_files $uri $uri/ /index.html;
    }
}
  1. Save the file in the /etc/nginx/conf.d/ directory.
  2. Reload Nginx configuration with sudo nginx -s reload.
  3. Open localhost in a web browser to view your Vue.js project.

Helpful links

Edit this code on GitHub