mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2025-01-06 15:36:29 +00:00
20 lines
448 B
JavaScript
20 lines
448 B
JavaScript
import http from 'http'
|
|
import httpProxy from 'http-proxy'
|
|
|
|
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)
|
|
|
|
server.on('error', () => start())
|
|
} catch (e) {
|
|
start()
|
|
}
|
|
}
|
|
|
|
start()
|