mirror of
https://github.com/coder/code-server.git
synced 2025-09-18 02:03:18 +08:00
Fix port parseInt error handling
parseInt returns NaN rather than throwing.
This commit is contained in:
@ -13,10 +13,8 @@ const getProxyTarget = (
|
|||||||
): string => {
|
): string => {
|
||||||
// If there is a base path, strip it out.
|
// If there is a base path, strip it out.
|
||||||
const base = (req as any).base || ""
|
const base = (req as any).base || ""
|
||||||
let port: number
|
const port = parseInt(req.params.port, 10)
|
||||||
try {
|
if (isNaN(port)) {
|
||||||
port = parseInt(req.params.port, 10)
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpError("Invalid port", HttpCode.BadRequest)
|
throw new HttpError("Invalid port", HttpCode.BadRequest)
|
||||||
}
|
}
|
||||||
return `http://0.0.0.0:${port}${opts?.proxyBasePath || ""}/${req.originalUrl.slice(base.length)}`
|
return `http://0.0.0.0:${port}${opts?.proxyBasePath || ""}/${req.originalUrl.slice(base.length)}`
|
||||||
|
Reference in New Issue
Block a user