Skip to content

TypeError: Protocol "http:" not supported. Expected "https:" #2348

Closed
@AmazingTurtle

Description

@AmazingTurtle

So yeah I spent like 2 hours deep dive debugging into this only to discover a bug.

javascript/src/config.ts

Lines 527 to 551 in 3283cb1

private createAgent(
cluster: Cluster | null,
agentOptions: https.AgentOptions,
): https.Agent | SocksProxyAgent | HttpProxyAgent | HttpsProxyAgent {
let agent: https.Agent | SocksProxyAgent | HttpProxyAgent | HttpsProxyAgent;
if (cluster && cluster.proxyUrl) {
if (cluster.proxyUrl.startsWith('socks')) {
agent = new SocksProxyAgent(cluster.proxyUrl, agentOptions);
} else if (cluster.server.startsWith('https')) {
const httpsProxyAgentOptions: HttpsProxyAgentOptions = agentOptions as HttpsProxyAgentOptions;
httpsProxyAgentOptions.proxy = cluster.proxyUrl;
agent = new HttpsProxyAgent(httpsProxyAgentOptions);
} else if (cluster.server.startsWith('http')) {
const httpProxyAgentOptions: HttpProxyAgentOptions = agentOptions as HttpProxyAgentOptions;
httpProxyAgentOptions.proxy = cluster.proxyUrl;
agent = new HttpProxyAgent(httpProxyAgentOptions);
} else {
throw new Error('Unsupported proxy type');
}
} else {
agent = new https.Agent(agentOptions);
}
return agent;
}

more specifically

javascript/src/config.ts

Lines 533 to 536 in 3283cb1

if (cluster && cluster.proxyUrl) {
if (cluster.proxyUrl.startsWith('socks')) {
agent = new SocksProxyAgent(cluster.proxyUrl, agentOptions);
} else if (cluster.server.startsWith('https')) {

if no proxyUrl is set, then the default will be an HTTPS agent, which does not work with kubectl proxy environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions