| | |
| | | const { createProxyMiddleware } = require('http-proxy-middleware'); |
| | | const app = express(); |
| | | const path = require('path'); |
| | | const fs = require('fs'); |
| | | const config = require(path.join(__dirname, '../dist/config')); |
| | | |
| | | // proxy 中间件的选择项 |
| | |
| | | // // res.sendFile(path.join(__dirname, '../dist/index.html')); |
| | | // }); |
| | | app.get('*', function(req, res) { |
| | | res.sendFile(path.join(__dirname, '../dist/index.html')); |
| | | const indexPath = config.NODE_ENV == 'production' ? '../dist/prod/index.html' : config.NODE_ENV == 'test' ? |
| | | '../dist/test/index.html' : '../dist/dev/index.html'; |
| | | const html = fs.readFileSync(path.resolve(__dirname, indexPath), 'utf-8'); |
| | | res.send(html); |
| | | }); |
| | | app.listen(config.APP_SERVER_PORT, '0.0.0.0', function(err) { |
| | | if (err) { |