Support sub-path deploy via NEXT_PUBLIC_BASE_PATH (loma.chat/pagiva)
Adds basePath config, withBase/appUrl helpers, base-path-aware cookies, OAuth redirects, manifest, service worker and cron runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+6
-4
@@ -1,11 +1,13 @@
|
||||
// Service worker: installable app shell + offline fallback.
|
||||
// Never caches API responses or page HTML — they carry per-user, per-page data.
|
||||
const VERSION = "pm-v4";
|
||||
const VERSION = "pm-v5";
|
||||
const STATIC_CACHE = `${VERSION}-static`;
|
||||
const OFFLINE_URL = "/offline.html";
|
||||
// Base path ("" or "/pagiva") comes from the registration scope.
|
||||
const BASE = new URL(self.registration.scope).pathname.replace(/\/$/, "");
|
||||
const OFFLINE_URL = `${BASE}/offline.html`;
|
||||
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(caches.open(STATIC_CACHE).then((c) => c.addAll([OFFLINE_URL, "/icons/192"])));
|
||||
event.waitUntil(caches.open(STATIC_CACHE).then((c) => c.addAll([OFFLINE_URL, `${BASE}/icons/192`])));
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
@@ -29,7 +31,7 @@ self.addEventListener("fetch", (event) => {
|
||||
}
|
||||
|
||||
// Build assets are content-hashed: cache-first is safe.
|
||||
if (url.pathname.startsWith("/_next/static/") || url.pathname.startsWith("/icons/")) {
|
||||
if (url.pathname.startsWith(`${BASE}/_next/static/`) || url.pathname.startsWith(`${BASE}/icons/`)) {
|
||||
event.respondWith(
|
||||
caches.match(req).then(
|
||||
(hit) =>
|
||||
|
||||
Reference in New Issue
Block a user