@@ -4,7 +4,7 @@ import fastifyStatic from '@fastify/static';
44import fastifyWebsocket from '@fastify/websocket' ;
55import { fileURLToPath } from 'node:url' ;
66import { dirname , join , resolve } from 'node:path' ;
7- import { existsSync } from 'node:fs' ;
7+ import { existsSync , readFileSync } from 'node:fs' ;
88import { registerProjectRoutes } from './routes/project.js' ;
99import { registerAgentRoutes } from './routes/agents.js' ;
1010import { registerPlanetRoutes } from './routes/planets.js' ;
@@ -48,7 +48,19 @@ export async function startServer(opts: ServeOptions): Promise<void> {
4848
4949 function sendSpaEntry ( reply : { sendFile : ( path : string ) => unknown ; code : ( status : number ) => any ; header : ( key : string , value : string ) => any ; send : ( body : string ) => unknown ; } ) {
5050 if ( hasBuiltStudio ( ) ) {
51- return reply . sendFile ( 'dist/index.html' ) ;
51+ // Avoid stale HTML cache in mobile in-app browsers (hashed asset names change on deploy).
52+ // `sendFile()` may override cache headers, so we manually send the HTML.
53+ try {
54+ const html = readFileSync ( builtIndexPath , 'utf-8' ) ;
55+ return reply
56+ . code ( 200 )
57+ . header ( 'content-type' , 'text/html; charset=utf-8' )
58+ . header ( 'cache-control' , 'no-store' )
59+ . send ( html ) ;
60+ } catch {
61+ // Fallback to the static handler if for some reason the file is not readable.
62+ return reply . sendFile ( 'dist/index.html' ) ;
63+ }
5264 }
5365
5466 return reply . code ( 200 ) . header ( 'content-type' , 'text/html' ) . send ( getEmbeddedHtml ( ) ) ;
0 commit comments