Add SPA fallback to serve index.html for unmatched paths
This commit is contained in:
parent
91424230c7
commit
bf15bc3a3c
|
|
@ -33,6 +33,12 @@ export async function serveStatic(appName: string, req: Request): Promise<Respon
|
||||||
return new Response(Bun.file(htmlPath))
|
return new Response(Bun.file(htmlPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPA fallback: serve root index.html for unmatched paths
|
||||||
|
const rootIndex = join(pubDir, 'index.html')
|
||||||
|
if (existsSync(rootIndex)) {
|
||||||
|
return new Response(Bun.file(rootIndex))
|
||||||
|
}
|
||||||
|
|
||||||
return new Response('Not Found', { status: 404 })
|
return new Response('Not Found', { status: 404 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user