mirror of
https://github.com/cdr/code-server.git
synced 2025-12-06 08:27:17 +01:00
Fix port parseInt error handling
parseInt returns NaN rather than throwing.
This commit is contained in:
parent
2c9b4e7fd5
commit
9bd3b83ef5
1 changed files with 2 additions and 4 deletions
|
|
@ -13,10 +13,8 @@ const getProxyTarget = (
|
|||
): string => {
|
||||
// If there is a base path, strip it out.
|
||||
const base = (req as any).base || ""
|
||||
let port: number
|
||||
try {
|
||||
port = parseInt(req.params.port, 10)
|
||||
} catch (err) {
|
||||
const port = parseInt(req.params.port, 10)
|
||||
if (isNaN(port)) {
|
||||
throw new HttpError("Invalid port", HttpCode.BadRequest)
|
||||
}
|
||||
return `http://0.0.0.0:${port}${opts?.proxyBasePath || ""}/${req.originalUrl.slice(base.length)}`
|
||||
|
|
|
|||
Loading…
Reference in a new issue