Skip to content

Instantly share code, notes, and snippets.

@wxingheng
Created August 28, 2018 09:56
Show Gist options
  • Save wxingheng/39682deefa15c55260881b471fd7583a to your computer and use it in GitHub Desktop.
Save wxingheng/39682deefa15c55260881b471fd7583a to your computer and use it in GitHub Desktop.
express 404 router express 默认路由的匹配
**配置**
目前我是用于前端的单页应用路由匹配
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