5 changed files with 21 additions and 19 deletions
@ -1,6 +1,6 @@
|
||||
[package] |
||||
name = "cryptgeon" |
||||
version = "1.3.2" |
||||
version = "1.3.3" |
||||
authors = ["cupcakearmy <[email protected]>"] |
||||
edition = "2021" |
||||
|
||||
|
@ -1,19 +1,15 @@
|
||||
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) |
||||
const proxy = httpProxy.createProxyServer() |
||||
proxy.on('error', function (err, req, res) { |
||||
res.writeHead(500, { 'Content-Type': 'text/plain' }) |
||||
res.end('500 Internal Server Error') |
||||
}) |
||||
|
||||
server.on('error', () => start()) |
||||
} catch (e) { |
||||
start() |
||||
} |
||||
} |
||||
|
||||
start() |
||||
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) |
||||
console.log('Proxy on http://localhost:1234') |
||||
|
Loading…
Reference in new issue