Skip to content

Commit

Permalink
fix(gatsby): fix --https option for develop (#36248)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Jul 27, 2022
1 parent 5a5f5b9 commit abc65a6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 0 additions & 2 deletions packages/gatsby/src/commands/develop.ts
Expand Up @@ -236,8 +236,6 @@ module.exports = async (program: IProgram): Promise<void> => {
port: developPort,
// TODO(v5): remove
proxyPort: developPort,
// Don't pass SSL options down to the develop process, it should always use HTTP
ssl: null,
debugInfo,
})};
cmd(args);
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/commands/types.ts
Expand Up @@ -3,8 +3,8 @@ import { Store, AnyAction } from "redux"
import { IGatsbyState } from "../redux/types"

export interface ICert {
key: Buffer
cert: Buffer
key: string
cert: string
}

export interface IDebugInfo {
Expand Down
8 changes: 4 additions & 4 deletions packages/gatsby/src/utils/get-ssl-cert.ts
Expand Up @@ -66,8 +66,8 @@ export async function getSslCert({
? absoluteOrDirectory(directory, caFile)
: certPath
return {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath),
key: fs.readFileSync(keyPath, `utf-8`),
cert: fs.readFileSync(certPath, `utf-8`),
}
}

Expand Down Expand Up @@ -98,8 +98,8 @@ export async function getSslCert({
process.env.NODE_EXTRA_CA_CERTS = caPath
}
return {
key,
cert,
key: key.toString(),
cert: cert.toString(),
}
} catch (err) {
report.panic({
Expand Down
7 changes: 5 additions & 2 deletions packages/gatsby/src/utils/start-server.ts
Expand Up @@ -15,6 +15,7 @@ import {
} from "graphql"
import { slash, uuid } from "gatsby-core-utils"
import http from "http"
import https from "https"
import cors from "cors"
import telemetry from "gatsby-telemetry"
import launchEditor from "react-dev-utils/launchEditor"
Expand Down Expand Up @@ -59,7 +60,7 @@ type ActivityTracker = any // TODO: Replace this with proper type once reporter

interface IServer {
compiler: webpack.Compiler
listener: http.Server
listener: http.Server | https.Server
webpackActivity: ActivityTracker
websocketManager: WebsocketManager
workerPool: WorkerPool.GatsbyWorkerPool
Expand Down Expand Up @@ -799,7 +800,9 @@ export async function startServer(
/**
* Set up the HTTP server and socket.io.
**/
const server = new http.Server(app)
const server = program.ssl
? new https.Server(program.ssl, app)
: new http.Server(app)
const socket = websocketManager.init({ server })
const listener = server.listen(program.port, program.host)

Expand Down

0 comments on commit abc65a6

Please sign in to comment.