This commit is contained in:
2023-01-04 19:40:37 +01:00
parent da527a0857
commit ad6f136dd0
7 changed files with 71 additions and 5 deletions

View File

@@ -3,12 +3,13 @@ import httpProxy from 'http-proxy'
const proxy = httpProxy.createProxyServer()
proxy.on('error', function (err, req, res) {
console.error(err)
res.writeHead(500, { 'Content-Type': 'text/plain' })
res.end('500 Internal Server Error')
})
const server = http.createServer(function (req, res) {
const target = req.url.startsWith('/api/') ? 'http://localhost:5000' : 'http://localhost:3000'
const target = req.url.startsWith('/api/') ? 'http://127.0.0.1:5000' : 'http://localhost:3000'
proxy.web(req, res, { target })
})
server.listen(1234)