File tree 2 files changed +5
-18
lines changed
2 files changed +5
-18
lines changed Original file line number Diff line number Diff line change
1
+ import crypto from 'node:crypto'
1
2
import { PassThrough } from 'node:stream'
2
3
import { styleText } from 'node:util'
3
4
import { contentSecurity } from '@nichtsam/helmet/content'
@@ -26,13 +27,8 @@ const MODE = process.env.NODE_ENV ?? 'development'
26
27
type DocRequestArgs = Parameters < HandleDocumentRequestFunction >
27
28
28
29
export default async function handleRequest ( ...args : DocRequestArgs ) {
29
- const [
30
- request ,
31
- responseStatusCode ,
32
- responseHeaders ,
33
- reactRouterContext ,
34
- loadContext ,
35
- ] = args
30
+ const [ request , responseStatusCode , responseHeaders , reactRouterContext ] =
31
+ args
36
32
const { currentInstance, primaryInstance } = await getInstanceInfo ( )
37
33
responseHeaders . set ( 'fly-region' , process . env . FLY_REGION ?? 'unknown' )
38
34
responseHeaders . set ( 'fly-app' , process . env . FLY_APP_NAME ?? 'unknown' )
@@ -47,7 +43,7 @@ export default async function handleRequest(...args: DocRequestArgs) {
47
43
? 'onAllReady'
48
44
: 'onShellReady'
49
45
50
- const nonce = loadContext . cspNonce ? .toString ( ) ?? ''
46
+ const nonce = crypto . randomBytes ( 16 ) . toString ( 'hex' )
51
47
return new Promise ( async ( resolve , reject ) => {
52
48
let didError = false
53
49
// NOTE: this timing will only include things that are rendered in the shell
Original file line number Diff line number Diff line change 1
- import crypto from 'node:crypto'
2
1
import { styleText } from 'node:util'
3
2
import { helmet } from '@nichtsam/helmet/node-http'
4
3
import { createRequestHandler } from '@react-router/express'
@@ -110,11 +109,6 @@ app.use(
110
109
} ) ,
111
110
)
112
111
113
- app . use ( ( _ , res , next ) => {
114
- res . locals . cspNonce = crypto . randomBytes ( 16 ) . toString ( 'hex' )
115
- next ( )
116
- } )
117
-
118
112
// When running tests or running in development, we want to effectively disable
119
113
// rate limiting because playwright tests are very fast and we don't want to
120
114
// have to wait for the rate limit to reset between tests.
@@ -201,10 +195,7 @@ if (!ALLOW_INDEXING) {
201
195
app . all (
202
196
'*' ,
203
197
createRequestHandler ( {
204
- getLoadContext : ( _ : any , res : any ) => ( {
205
- cspNonce : res . locals . cspNonce ,
206
- serverBuild : getBuild ( ) ,
207
- } ) ,
198
+ getLoadContext : ( ) => ( { serverBuild : getBuild ( ) } ) ,
208
199
mode : MODE ,
209
200
build : async ( ) => {
210
201
const { error, build } = await getBuild ( )
You can’t perform that action at this time.
0 commit comments