'How do I configure http-server for history mode in Vue JS 2?
I have a Vue JS application built in the directory dist. For running I use http-server installed globally by the command:
npm install -g http-server
I run the app with the command:
http-server dist
So I can reach the website on http://localhost:8080, it works correct. But in my app I have vue-router that is configured with history mode, so I should access the URLs like http://localhost:8080/page1, but the problem is http-server returns 404:
curl -i http://localhost:8080/page1
HTTP/1.1 404 Not Found
accept-ranges: bytes
Date: Sat, 11 Sep 2021 12:41:53 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 0
How do I fix it?
Solution 1:[1]
I believe that the fix is to run http-server with the "proxy" option as a "Catch-All" redirect - http-server -P http://localhost:8080? dist

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | IVO GELOV |
