forked from umijs/umi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (24 loc) · 735 Bytes
/
server.js
File metadata and controls
28 lines (24 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const express = require('express');
const fs = require('fs');
const app = express();
const languages = ['en', 'zh-Hans'];
app.use(function (req, res, next) {
// autodetect language
if (req.path === '/') {
if (req.subdomains[0] === 'ali') {
res.redirect('https://lark.alipay.com/umijs/umi');
return;
}
// const lang = [req.query.locale, req.subdomains[0], req.acceptsLanguages(...languages), 'en'].find(function (lang) {
// return languages.includes(lang);
// });
// req.url = '/' + lang + req.url;
// res.setHeader('Content-Language', lang);
}
next();
});
app.use(express.static(__dirname + '/build', {
maxAge: 60000
}));
app.listen(5000);
console.log('Listening on port 5000');