The service worker version had never moved past 1.0.0 and nothing on the page said which build was loaded, so an old cached shell looked identical to a fresh one. - public/version.json: app, version, builtAt, pwa - sw.js VERSION -> 2026.10.24.1 (new cache name, old caches dropped on activate) - next.config: sw.js and version.json are served no-cache, no-store, plus Service-Worker-Allowed: / ; ui-manifest.json must-revalidate - layout: <html data-app-version> read from version.json at build time - PwaBoot: paints the version into the footer badge, polls /version.json (1.5s then every 5 min) and reloads once when it differs; guards against reload loops - footer shows v2026.10.24.1 in mono next to the copyright Verified: sw.js, /version.json and <html data-app-version> all report 2026.10.24.1, the footer badge shows it, and /stops renders the three search tabs with the near-me panel in its own tab.
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/** @type {import('next').NextConfig} */
|
|
const BACKEND_INTERNAL_URL =
|
|
process.env.BACKEND_INTERNAL_URL || "http://localhost:20001";
|
|
|
|
const nextConfig = {
|
|
reactStrictMode: true,
|
|
output: "standalone",
|
|
images: {
|
|
remotePatterns: [{ protocol: "http", hostname: "**" }, { protocol: "https", hostname: "**" }]
|
|
},
|
|
async headers() {
|
|
return [
|
|
{
|
|
/* sw.js และ version.json ต้องไม่ถูก HTTP cache — ไม่งั้นผู้ใช้ค้างรุ่นเก่า */
|
|
source: "/sw.js",
|
|
headers: [
|
|
{ key: "Cache-Control", value: "no-cache, no-store, must-revalidate" },
|
|
{ key: "Service-Worker-Allowed", value: "/" },
|
|
],
|
|
},
|
|
{
|
|
source: "/version.json",
|
|
headers: [{ key: "Cache-Control", value: "no-cache, no-store, must-revalidate" }],
|
|
},
|
|
{
|
|
source: "/ui-manifest.json",
|
|
headers: [{ key: "Cache-Control", value: "public, max-age=0, must-revalidate" }],
|
|
},
|
|
];
|
|
},
|
|
async rewrites() {
|
|
return [
|
|
{
|
|
source: "/api/:path*",
|
|
destination: `${BACKEND_INTERNAL_URL}/api/:path*`
|
|
}
|
|
];
|
|
}
|
|
};
|
|
export default nextConfig;
|