mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
fix: proxy service now catches handler exceptions properly
This commit is contained in:
parent
91ef1f928e
commit
e3bd7a17d5
@ -22,7 +22,7 @@ export type ProxyMiddleware = (
|
|||||||
proxy: Server
|
proxy: Server
|
||||||
host: string
|
host: string
|
||||||
}
|
}
|
||||||
) => void
|
) => void | Promise<void>
|
||||||
|
|
||||||
export type ProxyServiceConfig = {
|
export type ProxyServiceConfig = {
|
||||||
coreInternalUrl: string
|
coreInternalUrl: string
|
||||||
@ -56,8 +56,8 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
|
|||||||
await m(req, res)
|
await m(req, res)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const msg = `${e}`
|
const msg = (() => (e instanceof Error ? e.message : `${e}`))()
|
||||||
error(msg)
|
warn(msg)
|
||||||
res.writeHead(403, {
|
res.writeHead(403, {
|
||||||
'Content-Type': `text/plain`,
|
'Content-Type': `text/plain`,
|
||||||
})
|
})
|
||||||
@ -133,7 +133,7 @@ export const proxyService = mkSingleton(async (config: ProxyServiceConfig) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
dbg(`${url} matches ${urlFilters}, sending to handler`)
|
dbg(`${url} matches ${urlFilters}, sending to handler`)
|
||||||
handler(req, res, { host, subdomain, coreInternalUrl, proxy })
|
return handler(req, res, { host, subdomain, coreInternalUrl, proxy })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user