File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
packages/react-router-dev/vite Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @react-router/dev " : patch
3
+ ---
4
+
5
+ Properly handle ` https ` protocol in dev mode
Original file line number Diff line number Diff line change 1
- import type { IncomingMessage , ServerResponse } from "node:http" ;
2
1
import { once } from "node:events" ;
2
+ import type { IncomingMessage , ServerResponse } from "node:http" ;
3
+ import { TLSSocket } from "node:tls" ;
3
4
import { Readable } from "node:stream" ;
4
5
import { splitCookiesString } from "set-cookie-parser" ;
5
6
import { createReadableStreamFromReadable } from "@react-router/node" ;
@@ -48,10 +49,14 @@ export function fromNodeRequest(
48
49
nodeReq : Vite . Connect . IncomingMessage ,
49
50
nodeRes : ServerResponse < Vite . Connect . IncomingMessage >
50
51
) : Request {
52
+ let protocol =
53
+ nodeReq . socket instanceof TLSSocket && nodeReq . socket . encrypted
54
+ ? "https"
55
+ : "http" ;
51
56
let origin =
52
57
nodeReq . headers . origin && "null" !== nodeReq . headers . origin
53
58
? nodeReq . headers . origin
54
- : `http ://${ nodeReq . headers . host } ` ;
59
+ : `${ protocol } ://${ nodeReq . headers . host } ` ;
55
60
// Use `req.originalUrl` so React Router is aware of the full path
56
61
invariant (
57
62
nodeReq . originalUrl ,
You can’t perform that action at this time.
0 commit comments