parent
8cee6579e2
commit
33829768eb
5 changed files with 28 additions and 13 deletions
@ -1,11 +1,19 @@ |
||||
import http from 'http' |
||||
import httpProxy from 'http-proxy' |
||||
|
||||
const proxy = httpProxy.createProxyServer({}) |
||||
function start() { |
||||
try { |
||||
const proxy = httpProxy.createProxyServer({}) |
||||
const server = http.createServer(function (req, res) { |
||||
const target = req.url.startsWith('/api/') ? 'http://localhost:5000' : 'http://localhost:3000' |
||||
proxy.web(req, res, { target }) |
||||
}) |
||||
server.listen(1234) |
||||
|
||||
var server = http.createServer(function (req, res) { |
||||
const target = req.url.startsWith('/api/') ? 'http://localhost:5000' : 'http://localhost:3000' |
||||
proxy.web(req, res, { target }) |
||||
}) |
||||
server.on('error', () => start()) |
||||
} catch (e) { |
||||
start() |
||||
} |
||||
} |
||||
|
||||
server.listen(1234) |
||||
start() |
||||
|
Loading…
Reference in new issue