Advertisement
Guest User

Untitled

a guest
May 21st, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const express = require('express');
  3. const proxy = require('express-http-proxy');
  4.  
  5. const server = express();
  6. const file = path.join(__dirname, 'dist/index.html');
  7.  
  8. const PROTOCOL = 'http';
  9. const HOST = 'localhost';
  10. const PORT = 8000;
  11.  
  12. server.use(express.static(path.join(__dirname, 'dist')));
  13.  
  14. // all request proxy to root ('/')
  15. //server.use(/\/\w+/, proxy(`${HOST}:${PORT}`));
  16.  
  17. server.get('/test', (req, res) => {
  18.   res.sendFile(file);
  19. });
  20.  
  21.  
  22. server.listen(PORT, HOST, () => console.log(`Sever start on ${PROTOCOL}://${HOST}:${PORT}`));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement