createClient doesn't work with URL on port 80 or 443 since 1.0.0
martoche opened this issue · 2 comments
Describe the bug
Can't connect to a Clickhouse server that listens on port 443 (or when a reverse proxy on port 443 is used to forward requests to the Clickhouse server on any other port).
The following code :
const clickhouseClient = createClient({
url: "https://localhost:443",
pathname: "clickhouse",
database: "apm",
})
Throws the error: Uncaught Error: ClickHouse URL must contain a valid port number.
This is because of these lines:
clickhouse-js/packages/client-common/src/config.ts
Lines 286 to 288 in 64b5f81
The condition in the if
is incorrect: when the URL scheme is "http" and the port is explicitely set as "80", then new URL("http://localhost:80").port
is equal to the empty string. Similarily, new URL("https://localhost:443").port === ""
.
This is a regression of version 1.0.0, it works in 0.3.1.
Configuration
Environment
- Client version: 1.0.0 (web)
On it, thanks for the report.