staticServer.js 656 B

123456789101112131415161718192021222324252627
  1. const express = require('express');
  2. const debug = require('debug')('app:server');
  3. const proxy = require('http-proxy-middleware');
  4. const config = require('../config');
  5. const app = express();
  6. const paths = config.utils_paths;
  7. for (let i in config.proxy) {
  8. app.use(
  9. proxy(config.proxy[i].from, {
  10. target: config.proxy[i].target,
  11. changeOrigin: true,
  12. pathRewrite: {
  13. [config.proxy[i].from]: config.proxy[i].to,
  14. },
  15. }),
  16. );
  17. }
  18. // app.use(require('connect-history-api-fallback')());
  19. debug('start static server!');
  20. // app.use(express.static(paths.dist()));
  21. // app.use(express.static(paths.lib()));
  22. module.exports = app;