@@ -31,7 +31,12 @@ const server = createServer(async (req, res) => {
3131 const pathname = url . pathname ;
3232
3333 // Try to serve static files from dist/client first
34- if ( pathname . startsWith ( '/assets/' ) || pathname === '/favicon.svg' || pathname === '/favicon.png' || pathname === '/favicon.ico' ) {
34+ // Serve: /assets/*, *.js, *.css, *.json, images, fonts, favicons
35+ const staticExtensions = [ '.js' , '.mjs' , '.css' , '.json' , '.png' , '.jpg' , '.gif' , '.ico' , '.svg' , '.woff' , '.woff2' ] ;
36+ const isStaticFile = pathname . startsWith ( '/assets/' ) ||
37+ staticExtensions . some ( ext => pathname . endsWith ( ext ) ) ;
38+
39+ if ( isStaticFile ) {
3540 try {
3641 const filePath = join ( __dirname , 'dist' , 'client' , pathname ) ;
3742 const content = await readFile ( filePath ) ;
@@ -67,7 +72,14 @@ const server = createServer(async (req, res) => {
6772 } ) ;
6873
6974 // Call the TanStack Start fetch handler
75+ const ssrStart = Date . now ( ) ;
7076 const response = await serverHandler . fetch ( request ) ;
77+ const ssrTime = Date . now ( ) - ssrStart ;
78+
79+ // Log slow SSR requests
80+ if ( ssrTime > 1000 ) {
81+ console . log ( `⚠️ SLOW SSR: ${ req . method } ${ pathname } took ${ ssrTime } ms` ) ;
82+ }
7183
7284 // Convert Web Standard Response to Node.js response
7385 res . statusCode = response . status ;
@@ -77,6 +89,11 @@ const server = createServer(async (req, res) => {
7789 response . headers . forEach ( ( value , key ) => {
7890 res . setHeader ( key , value ) ;
7991 } ) ;
92+
93+ // Prevent caching of HTML to avoid stale chunk references for now
94+ if ( response . headers . get ( 'content-type' ) ?. includes ( 'text/html' ) ) {
95+ res . setHeader ( 'Cache-Control' , 'no-store, no-cache, must-revalidate' ) ;
96+ }
8097
8198 // Stream the response body
8299 if ( response . body ) {
0 commit comments