Help Center/ Object Storage Service/ FAQs/ Static Website Hosting/ What Can I Do If Error 404 Is Displayed Upon Page Refresh When Vue Router Is Configured in History Mode?
Updated on 2026-09-14 GMT+08:00

What Can I Do If Error 404 Is Displayed Upon Page Refresh When Vue Router Is Configured in History Mode?

The Vue framework supports two routing modes, hash mode and history mode. The hash mode (URL example: example.com/#/user) does not require server configuration, while the history mode (URL example: example.com/user) is more visually appealing but requires server configuration.

Symptom: In history mode, when a user directly accesses a non-home page (for example, example.com/user), the server searches for the corresponding physical file (/user). If the file does not exist, the server returns a 404 error.

Solution: When configuring static website hosting, set the default 404 error page to index.html. In this way, when a non-home page does not exist, all paths are redirected to the home page of the application, and the frontend JavaScript correctly processes the route.