Skip to content

Commit

Permalink
chore: import https instead of using require
Browse files Browse the repository at this point in the history
  • Loading branch information
manast authored Sep 14, 2024
1 parent 178bf53 commit bde77bc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from 'path';
import { URL, parse as parseUrl } from 'url';
import cluster from 'cluster';
import http, { Agent, ClientRequest, IncomingMessage, ServerResponse } from 'http';
import https from 'https';
import fs from 'fs';
import tls from 'tls';

Expand Down Expand Up @@ -310,7 +311,7 @@ export class Redbird {
}

setupHttpsProxy(proxy: httpProxy, websocketsUpgrade: any, sslOpts: any) {
let https;
let httpsModule;
this.certs = this.certs || {};
const certs = this.certs;

Expand Down Expand Up @@ -350,15 +351,15 @@ export class Redbird {
}

if (sslOpts.http2) {
https = sslOpts.serverModule || require('spdy');
httpsModule = sslOpts.serverModule || require('spdy');
if (isObject(sslOpts.http2)) {
sslOpts.spdy = sslOpts.http2;
}
} else {
https = sslOpts.serverModule || require('https');
httpsModule = sslOpts.serverModule || https;
}

const httpsServer = (this.httpsServer = https.createServer(
const httpsServer = (this.httpsServer = httpsModule.createServer(
ssl,
async (req: IncomingMessage, res: ServerResponse) => {
const src = this.getSource(req);
Expand Down

0 comments on commit bde77bc

Please sign in to comment.