File tree Expand file tree Collapse file tree 2 files changed +5
-18
lines changed Expand file tree Collapse file tree 2 files changed +5
-18
lines changed Original file line number Diff line number Diff line change 1+ import crypto from 'node:crypto'
12import { PassThrough } from 'node:stream'
23import { styleText } from 'node:util'
34import { contentSecurity } from '@nichtsam/helmet/content'
@@ -26,13 +27,8 @@ const MODE = process.env.NODE_ENV ?? 'development'
2627type DocRequestArgs = Parameters < HandleDocumentRequestFunction >
2728
2829export 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
3632 const { currentInstance, primaryInstance } = await getInstanceInfo ( )
3733 responseHeaders . set ( 'fly-region' , process . env . FLY_REGION ?? 'unknown' )
3834 responseHeaders . set ( 'fly-app' , process . env . FLY_APP_NAME ?? 'unknown' )
@@ -47,7 +43,7 @@ export default async function handleRequest(...args: DocRequestArgs) {
4743 ? 'onAllReady'
4844 : 'onShellReady'
4945
50- const nonce = loadContext . cspNonce ? .toString ( ) ?? ''
46+ const nonce = crypto . randomBytes ( 16 ) . toString ( 'hex' )
5147 return new Promise ( async ( resolve , reject ) => {
5248 let didError = false
5349 // 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'
21import { styleText } from 'node:util'
32import { helmet } from '@nichtsam/helmet/node-http'
43import { createRequestHandler } from '@react-router/express'
@@ -110,11 +109,6 @@ app.use(
110109 } ) ,
111110)
112111
113- app . use ( ( _ , res , next ) => {
114- res . locals . cspNonce = crypto . randomBytes ( 16 ) . toString ( 'hex' )
115- next ( )
116- } )
117-
118112// When running tests or running in development, we want to effectively disable
119113// rate limiting because playwright tests are very fast and we don't want to
120114// have to wait for the rate limit to reset between tests.
@@ -201,10 +195,7 @@ if (!ALLOW_INDEXING) {
201195app . all (
202196 '*' ,
203197 createRequestHandler ( {
204- getLoadContext : ( _ : any , res : any ) => ( {
205- cspNonce : res . locals . cspNonce ,
206- serverBuild : getBuild ( ) ,
207- } ) ,
198+ getLoadContext : ( ) => ( { serverBuild : getBuild ( ) } ) ,
208199 mode : MODE ,
209200 build : async ( ) => {
210201 const { error, build } = await getBuild ( )
You can’t perform that action at this time.
0 commit comments