Skip to content

Commit abc65a6

Browse files
authoredJul 27, 2022
fix(gatsby): fix --https option for develop (#36248)

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed
 

‎packages/gatsby/src/commands/develop.ts

-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ module.exports = async (program: IProgram): Promise<void> => {
236236
port: developPort,
237237
// TODO(v5): remove
238238
proxyPort: developPort,
239-
// Don't pass SSL options down to the develop process, it should always use HTTP
240-
ssl: null,
241239
debugInfo,
242240
})};
243241
cmd(args);

‎packages/gatsby/src/commands/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Store, AnyAction } from "redux"
33
import { IGatsbyState } from "../redux/types"
44

55
export interface ICert {
6-
key: Buffer
7-
cert: Buffer
6+
key: string
7+
cert: string
88
}
99

1010
export interface IDebugInfo {

‎packages/gatsby/src/utils/get-ssl-cert.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export async function getSslCert({
6666
? absoluteOrDirectory(directory, caFile)
6767
: certPath
6868
return {
69-
key: fs.readFileSync(keyPath),
70-
cert: fs.readFileSync(certPath),
69+
key: fs.readFileSync(keyPath, `utf-8`),
70+
cert: fs.readFileSync(certPath, `utf-8`),
7171
}
7272
}
7373

@@ -98,8 +98,8 @@ export async function getSslCert({
9898
process.env.NODE_EXTRA_CA_CERTS = caPath
9999
}
100100
return {
101-
key,
102-
cert,
101+
key: key.toString(),
102+
cert: cert.toString(),
103103
}
104104
} catch (err) {
105105
report.panic({

‎packages/gatsby/src/utils/start-server.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from "graphql"
1616
import { slash, uuid } from "gatsby-core-utils"
1717
import http from "http"
18+
import https from "https"
1819
import cors from "cors"
1920
import telemetry from "gatsby-telemetry"
2021
import launchEditor from "react-dev-utils/launchEditor"
@@ -59,7 +60,7 @@ type ActivityTracker = any // TODO: Replace this with proper type once reporter
5960

6061
interface IServer {
6162
compiler: webpack.Compiler
62-
listener: http.Server
63+
listener: http.Server | https.Server
6364
webpackActivity: ActivityTracker
6465
websocketManager: WebsocketManager
6566
workerPool: WorkerPool.GatsbyWorkerPool
@@ -799,7 +800,9 @@ export async function startServer(
799800
/**
800801
* Set up the HTTP server and socket.io.
801802
**/
802-
const server = new http.Server(app)
803+
const server = program.ssl
804+
? new https.Server(program.ssl, app)
805+
: new http.Server(app)
803806
const socket = websocketManager.init({ server })
804807
const listener = server.listen(program.port, program.host)
805808

0 commit comments

Comments
 (0)
Please sign in to comment.