Created
August 28, 2018 09:56
-
-
Save wxingheng/39682deefa15c55260881b471fd7583a to your computer and use it in GitHub Desktop.
express 404 router express 默认路由的匹配
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**配置** | |
目前我是用于前端的单页应用路由匹配 | |
app.js | |
```language | |
const express = require('express'); | |
const localServer = express(); | |
// 静态资源 | |
localServer.use(express.static(path.join(__dirname, 'www'))); | |
// 匹配找不到的页面 (我们的单页引用就指向 index.html) | |
localServer.get('*', function (req, res) { | |
res.sendfile('./www/index.html'); | |
}) | |
localServer.listen(3001); | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment