mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
proxy error fix
This commit is contained in:
parent
b77e9cdb3a
commit
338c4bc32b
@ -9,6 +9,9 @@ const options = {
|
||||
}
|
||||
|
||||
const proxy = httpProxy.createProxyServer({})
|
||||
proxy.on('error', (e) => {
|
||||
console.error(e)
|
||||
})
|
||||
|
||||
const server = createServer(options, async (req, res) => {
|
||||
const headers = {
|
||||
@ -26,10 +29,17 @@ const server = createServer(options, async (req, res) => {
|
||||
|
||||
console.log(req.headers.host)
|
||||
const { host } = req.headers
|
||||
if (host === process.env.PUBLIC_APP_DOMAIN) {
|
||||
proxy.web(req, res, { target: `http://localhost:5173` })
|
||||
} else {
|
||||
proxy.web(req, res, { target: `http://localhost:3000` })
|
||||
|
||||
try {
|
||||
if (host === process.env.PUBLIC_APP_DOMAIN) {
|
||||
proxy.web(req, res, { target: `http://localhost:5173` })
|
||||
} else {
|
||||
proxy.web(req, res, { target: `http://localhost:3000` })
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`Got an error ${e}`)
|
||||
res.statusCode = 500
|
||||
res.end()
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user