From b0b58d2f1e0ed47ca13795b64595386ec2f0e0c7 Mon Sep 17 00:00:00 2001 From: b0txec Date: Mon, 24 Aug 2026 10:35:34 +0300 Subject: [PATCH] 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. --- src/main/scala/server/Server.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/scala/server/Server.scala b/src/main/scala/server/Server.scala index fa985e7..44ac37d 100644 --- a/src/main/scala/server/Server.scala +++ b/src/main/scala/server/Server.scala @@ -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()) }