Fom*_*aut 2 deployment httpserver vue.js vue-router vue-cli
我在目录中构建了一个 Vue JS 应用程序dist。为了运行,我使用http-server以下命令全局安装:
npm install -g http-server
Run Code Online (Sandbox Code Playgroud)
我使用以下命令运行应用程序:
http-server dist
Run Code Online (Sandbox Code Playgroud)
所以我可以访问该网站http://localhost:8080,它工作正常。但在我的应用程序中,我vue-router配置了历史记录模式,因此我应该访问类似 的 URL http://localhost:8080/page1,但问题是http-server返回 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
Run Code Online (Sandbox Code Playgroud)
我如何解决它?