English

Config Nginx For SPA

2/15/2024
36

In case the nginx web server can not find the `index.html` when refreshing the web page, we should config our web server to use a specific location if can not find the resource

Bash
location / {
  try_files $uri $uri/ /index.html;
}

refer to:

https://router.vuejs.org/guide/essentials/history-mode.html#nginx

https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files