- Wrap next.config.ts with @serwist/next (webpack mode, disabled in dev) - Service worker: NetworkOnly for /api/*, offline fallback → /~offline - Web app manifest via Next.js metadata API (app/manifest.ts) - PNG icon set generated with sharp (192, 512, maskable-512, apple-180) - iOS meta tags: appleWebApp, themeColor viewport export - Middleware: pwaAssets early-return so /sw.js never gets a 302→login - Offline fallback page at /~offline (static, no auth dependency) - InstallPrompt component: beforeinstallprompt (Android) + iOS Share sheet instructions - Logout (menu/page.tsx): purge all SW caches on signout (shared-device safety) - Fix invite/[token]/page.tsx params type for Next.js 16 (use(params)) - Build script: next build --webpack (Serwist requires webpack, not Turbopack) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import type { NextConfig } from "next";
|
|
import withSerwistInit from "@serwist/next";
|
|
|
|
const withSerwist = withSerwistInit({
|
|
swSrc: "src/app/sw.ts",
|
|
swDest: "public/sw.js",
|
|
// Disable in dev so it never interferes with HMR / hot reload
|
|
disable: process.env.NODE_ENV === "development",
|
|
});
|
|
|
|
const nextConfig: NextConfig = {
|
|
output: "standalone",
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/(.*)",
|
|
headers: [
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
|
|
{ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },
|
|
{ key: "Content-Security-Policy", value:
|
|
"default-src 'self'; " +
|
|
"img-src 'self' data: https://*.r2.cloudflarestorage.com https://*.r2.dev; " +
|
|
"script-src 'self' 'unsafe-inline' 'unsafe-eval'; " +
|
|
"style-src 'self' 'unsafe-inline'; " +
|
|
"connect-src 'self' https://llm.manohargupta.com; " +
|
|
"font-src 'self' data:;"
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default withSerwist(nextConfig);
|