| 123456789101112131415161718192021222324252627282930313233343536373839 |
- const express = require('express');
- const webpack = require('webpack');
- const webpackDevMiddleware = require('webpack-dev-middleware');
- const httpProxy = require("http-proxy");
- const app = express();
- const config = require('./webpack.remote.dev.js');
- const compiler = webpack(config);
- const port = process.env.remoteDevPort;
- var apiProxy = httpProxy.createProxyServer();
- // Tell express to use the webpack-dev-middleware and use the webpack.config.js
- // configuration file as a base.
- app.use(
- webpackDevMiddleware(compiler, {
- publicPath: '/',
- })
- );
- const proxyUrls = ['/api', '/static', '/content', '/dashboard', '/assets', '/authApi', '/Dictionary', '/Files', '/WebSocket', '/TrainVideo'];
- proxyUrls.forEach(proxyUrl => {
- // Proxy api requests
- app.use(proxyUrl + "/*", function (req, res) {
- req.url = req.baseUrl; // Janky hack...
- apiProxy.web(req, res, {
- target: {
- port: 10022,
- host: "localhost"
- }
- });
- });
- })
- // Serve the files on port 8081.
- app.listen(port, function () {
- console.log('Example app listening on port ' + port + '!\n');
- });
|