Gjør PWA-stier relative for fleksibel utrulling

Appen kan nå serveres både på / og under en understi som
/tilfluktsrom uten endringer.

- Sett base: './' i vite.config.ts
- Endre alle absolutte stier i index.html til relative
- Oppdater manifest.webmanifest med start_url: "." og scope: "."
- navigateFallback uten ledende skråstrek

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-03-23 15:35:39 +01:00
commit 85c3d6953c
3 changed files with 10 additions and 8 deletions

View file

@ -8,9 +8,9 @@
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://*.tile.openstreetmap.org; connect-src 'self' https://*.tile.openstreetmap.org; font-src 'self'; worker-src 'self'" />
<title>Tilfluktsrom</title>
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="icon" type="image/png" sizes="192x192" href="/icons/icon-192.png" />
<link rel="apple-touch-icon" href="/icons/icon-192.png" />
<link rel="manifest" href="manifest.webmanifest" />
<link rel="icon" type="image/png" sizes="192x192" href="icons/icon-192.png" />
<link rel="apple-touch-icon" href="icons/icon-192.png" />
</head>
<body>
<div id="app">
@ -63,6 +63,6 @@
</div>
</div>
<script type="module" src="/src/main.ts"></script>
<script type="module" src="src/main.ts"></script>
</body>
</html>

View file

@ -2,20 +2,21 @@
"name": "Tilfluktsrom",
"short_name": "Tilfluktsrom",
"description": "Find the nearest public shelter in Norway",
"start_url": "/",
"start_url": ".",
"scope": ".",
"display": "standalone",
"orientation": "portrait",
"theme_color": "#1A1A2E",
"background_color": "#1A1A2E",
"icons": [
{
"src": "/icons/icon-192.png",
"src": "icons/icon-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/icons/icon-512.png",
"src": "icons/icon-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"

View file

@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
export default defineConfig({
base: './',
define: {
// Injected as a global — changes every build, breaking any stale cache
__BUILD_REVISION__: JSON.stringify(
@ -21,7 +22,7 @@ export default defineConfig({
cleanupOutdatedCaches: true,
// SPA: serve index.html for all navigation requests
navigateFallback: '/index.html',
navigateFallback: 'index.html',
// Vite already hashes JS/CSS filenames — skip Workbox's
// cache-bust query parameter for those