Keep a missing /assets file a real 404 in the SPA fallback
A stale browser tab referencing a bundle removed by a later deploy should get a clean 404, not HTML served where JS was expected.
This commit is contained in:
@@ -211,6 +211,11 @@ class Server(postgresService: PostgresService, dataService: DataService, fetch:
|
||||
// real, observed on /faktiska and /udens-temperatura in production.
|
||||
private val assets = staticcontent.fileService[IO](FileService.Config("./web/dist"))
|
||||
private val spaFallback = HttpRoutes.of[IO] {
|
||||
// A missing file under /assets (the only place Vite emits hashed build
|
||||
// output) should stay a real 404, not silently serve HTML — otherwise a
|
||||
// stale tab referencing a since-removed bundle after a future deploy
|
||||
// would get a confusing "unexpected token" JS parse error instead.
|
||||
case GET -> Root / "assets" / _ => NotFound()
|
||||
case req @ GET -> _ =>
|
||||
StaticFile.fromPath(Path("./web/dist/index.html"), Some(req)).getOrElseF(NotFound())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user