@@ -15,20 +15,19 @@ import morgan from 'morgan'
1515installGlobals ( )
1616
1717const MODE = process . env . NODE_ENV ?? 'development'
18+ const IS_PROD = MODE === 'production'
1819
19- const createRequestHandler =
20- MODE === 'production'
21- ? Sentry . wrapExpressCreateRequestHandler ( _createRequestHandler )
22- : _createRequestHandler
20+ const createRequestHandler = IS_PROD
21+ ? Sentry . wrapExpressCreateRequestHandler ( _createRequestHandler )
22+ : _createRequestHandler
2323
24- const viteDevServer =
25- MODE === 'production'
26- ? undefined
27- : await import ( 'vite' ) . then ( vite =>
28- vite . createServer ( {
29- server : { middlewareMode : true } ,
30- } ) ,
31- )
24+ const viteDevServer = IS_PROD
25+ ? undefined
26+ : await import ( 'vite' ) . then ( vite =>
27+ vite . createServer ( {
28+ server : { middlewareMode : true } ,
29+ } ) ,
30+ )
3231
3332const app = express ( )
3433
@@ -84,7 +83,7 @@ if (viteDevServer) {
8483 app . use ( express . static ( 'build/client' , { maxAge : '1h' } ) )
8584}
8685
87- app . get ( [ '/img/*' , '/favicons/*' ] , ( req , res ) => {
86+ app . get ( [ '/img/*' , '/favicons/*' ] , ( _req , res ) => {
8887 // if we made it past the express.static for these, then we're missing something.
8988 // So we'll just send a 404 and won't bother calling other middleware.
9089 return res . status ( 404 ) . send ( 'Not found' )
@@ -108,6 +107,7 @@ app.use((_, res, next) => {
108107
109108app . use (
110109 helmet ( {
110+ xPoweredBy : false ,
111111 referrerPolicy : { policy : 'same-origin' } ,
112112 crossOriginEmbedderPolicy : false ,
113113 contentSecurityPolicy : {
@@ -142,7 +142,7 @@ app.use(
142142// rate limiting because playwright tests are very fast and we don't want to
143143// have to wait for the rate limit to reset between tests.
144144const maxMultiple =
145- MODE !== 'production' || process . env . PLAYWRIGHT_TEST_BASE_URL ? 10_000 : 1
145+ ! IS_PROD || process . env . PLAYWRIGHT_TEST_BASE_URL ? 10_000 : 1
146146const rateLimitDefault = {
147147 windowMs : 60 * 1000 ,
148148 max : 1000 * maxMultiple ,
@@ -212,8 +212,7 @@ app.all(
212212 serverBuild : getBuild ( ) ,
213213 } ) ,
214214 mode : MODE ,
215- // @sentry /remix needs to be updated to handle the function signature
216- build : MODE === 'production' ? await getBuild ( ) : getBuild ,
215+ build : getBuild ,
217216 } ) ,
218217)
219218
@@ -224,29 +223,25 @@ const portToUse = await getPort({
224223
225224const server = app . listen ( portToUse , ( ) => {
226225 const addy = server . address ( )
227- const portUsed =
228- desiredPort === portToUse
229- ? desiredPort
230- : addy && typeof addy === 'object'
231- ? addy . port
232- : 0
226+ const portActuallyUsed =
227+ addy === null || typeof addy === 'string' ? 0 : addy . port
233228
234- if ( portUsed !== desiredPort ) {
229+ if ( portActuallyUsed !== desiredPort ) {
235230 console . warn (
236231 chalk . yellow (
237- `⚠️ Port ${ desiredPort } is not available, using ${ portUsed } instead.` ,
232+ `⚠️ Port ${ desiredPort } is not available, using ${ portActuallyUsed } instead.` ,
238233 ) ,
239234 )
240235 }
241236 console . log ( `🚀 We have liftoff!` )
242- const localUrl = `http://localhost:${ portUsed } `
237+ const localUrl = `http://localhost:${ portActuallyUsed } `
243238 let lanUrl : string | null = null
244239 const localIp = ipAddress ( ) ?? 'Unknown'
245240 // Check if the address is a private ip
246241 // https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces
247242 // https://github.com/facebook/create-react-app/blob/d960b9e38c062584ff6cfb1a70e1512509a966e7/packages/react-dev-utils/WebpackDevServerUtils.js#LL48C9-L54C10
248243 if ( / ^ 1 0 [ . ] | ^ 1 7 2 [ . ] ( 1 [ 6 - 9 ] | 2 [ 0 - 9 ] | 3 [ 0 - 1 ] ) [ . ] | ^ 1 9 2 [ . ] 1 6 8 [ . ] / . test ( localIp ) ) {
249- lanUrl = `http://${ localIp } :${ portUsed } `
244+ lanUrl = `http://${ localIp } :${ portActuallyUsed } `
250245 }
251246
252247 console . log (
0 commit comments