2026-08-08 23:37:40 +00:00
|
|
|
/** @type {import('next').NextConfig} */
|
|
|
|
|
const nextConfig = {
|
|
|
|
|
reactStrictMode: true,
|
|
|
|
|
output: "standalone",
|
|
|
|
|
images: {
|
|
|
|
|
remotePatterns: [
|
|
|
|
|
// Allow image optimisation from any host. Lock this down once we
|
|
|
|
|
// know exactly which sources we'll pull attachments from.
|
|
|
|
|
{ protocol: "http", hostname: "**" },
|
|
|
|
|
{ protocol: "https", hostname: "**" },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
// Allow any host / IP / tunneled domain so the app is reachable from
|
|
|
|
|
// LAN devices, reverse proxies and custom hostnames. Next 16's
|
|
|
|
|
// internal matcher rejects the literal "*", so we also rely on the
|
|
|
|
|
// `scripts/patch-next-dev-blocker.cjs` postinstall hook to neuter
|
|
|
|
|
// the dev-only cross-site guard. Production behaviour is unaffected
|
|
|
|
|
// because the patch only runs in development.
|
|
|
|
|
allowedDevOrigins: ["*"],
|
|
|
|
|
experimental: {
|
|
|
|
|
serverActions: {
|
|
|
|
|
allowedOrigins: ["*"],
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-09-27 07:33:14 +00:00
|
|
|
// pdfmake's server-side PdfPrinter pulls in pdfkit -> @foliojs-fork/fontkit,
|
|
|
|
|
// which loads font-shaping tables (data.trie etc.) from a path relative to
|
|
|
|
|
// its own installed location at runtime. Webpack-bundled into a Server
|
|
|
|
|
// Component/Route Handler chunk, that relative lookup 404s (ENOENT) because
|
|
|
|
|
// the .trie files never get copied alongside the bundle. Left as native
|
|
|
|
|
// Node `require`, the real node_modules layout resolves them correctly —
|
|
|
|
|
// the same reason `sharp` and `@react-pdf/renderer` ship in Next's own
|
|
|
|
|
// default external-packages list.
|
|
|
|
|
serverExternalPackages: ["pdfmake", "pdfkit", "@foliojs-fork/fontkit"],
|
2026-08-08 23:37:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const withPWA = require("@ducanh2912/next-pwa").default({
|
2026-10-16 05:13:39 +00:00
|
|
|
// Development and production share public/sw.js. Never let a build-generated
|
|
|
|
|
// worker control HMR assets or rewrite the worker during local recompilation.
|
|
|
|
|
disable: process.env.NODE_ENV === "development",
|
2026-08-08 23:37:40 +00:00
|
|
|
dest: "public",
|
2026-09-28 21:51:47 +00:00
|
|
|
cacheOnFrontEndNav: false,
|
|
|
|
|
aggressiveFrontEndNavCaching: false,
|
2026-08-08 23:37:40 +00:00
|
|
|
reloadOnOnline: true,
|
|
|
|
|
register: true,
|
2026-09-25 05:27:12 +00:00
|
|
|
extendDefaultRuntimeCaching: true,
|
2026-08-08 23:37:40 +00:00
|
|
|
workboxOptions: {
|
|
|
|
|
cleanupOutdatedCaches: true,
|
|
|
|
|
clientsClaim: true,
|
|
|
|
|
skipWaiting: true,
|
2026-09-25 05:27:12 +00:00
|
|
|
runtimeCaching: [
|
2026-09-28 21:51:47 +00:00
|
|
|
// Account and site access can change at any time. A service worker
|
|
|
|
|
// must not replay another user's dashboard after sign-out.
|
|
|
|
|
{
|
|
|
|
|
urlPattern: ({ sameOrigin, url }) =>
|
|
|
|
|
sameOrigin && (/^\/(dashboard|clock|login|change-password)(\/|$)/.test(url.pathname) ||
|
|
|
|
|
url.pathname.startsWith("/api/")),
|
|
|
|
|
handler: "NetworkOnly",
|
|
|
|
|
},
|
2026-09-25 05:27:12 +00:00
|
|
|
// The QR confirmation must always use the server's current local-day
|
|
|
|
|
// decision. A cached yesterday lookup can say OUT while a POST writes IN.
|
|
|
|
|
{
|
|
|
|
|
urlPattern: ({ sameOrigin, url }) =>
|
|
|
|
|
sameOrigin && url.pathname === "/api/clock/employee-lookup",
|
|
|
|
|
handler: "NetworkOnly",
|
|
|
|
|
},
|
|
|
|
|
],
|
2026-08-08 23:37:40 +00:00
|
|
|
},
|
2026-08-30 20:33:35 +00:00
|
|
|
// The Web App Manifest lives at public/manifest.json (static file).
|
|
|
|
|
// next-pwa does NOT generate it — the `manifest` option was silently
|
|
|
|
|
// ignored in @ducanh2912/next-pwa@10.2.9. The dashboard metadata lives
|
|
|
|
|
// in public/manifest.json; the chat metadata lives in
|
|
|
|
|
// public/chat.webmanifest. Both are referenced from the per-route
|
|
|
|
|
// metadata blocks in src/app/layout.tsx and src/app/dashboard/chat/page.tsx.
|
2026-08-08 23:37:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = withPWA(nextConfig);
|