mirror of
https://github.com/coder/code-server.git
synced 2025-07-25 02:43:42 +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 => {
|
||||
// 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)}`
|
||||
|
Reference in New Issue
Block a user