The service worker served the cached page first, so a driver ran the old build until the app was opened twice (Joachim on 2026-10-26 kept the old one after the invoice-match deploy). Each build now writes its id to /version.json. On launch a newer live build clears the cached pages and reloads once; while the app stays open an Update banner appears instead, so a reload never cuts off a photo or an upload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
803 B
JavaScript
25 lines
803 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// One id per build, shared with the build workers through process.env (they
|
|
// inherit it), and written to public/version.json so a running app can ask
|
|
// the server which build is live (components/UpdateWatcher).
|
|
if (!process.env.NEXT_PUBLIC_BUILD_ID) {
|
|
process.env.NEXT_PUBLIC_BUILD_ID = Date.now().toString(36);
|
|
fs.writeFileSync(
|
|
path.join(__dirname, 'public', 'version.json'),
|
|
JSON.stringify({ id: process.env.NEXT_PUBLIC_BUILD_ID }) + '\n',
|
|
);
|
|
}
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
// Only use static export for production builds
|
|
...(process.env.NEXT_EXPORT === 'true' ? { output: 'export' } : {}),
|
|
images: {
|
|
unoptimized: true,
|
|
},
|
|
trailingSlash: true,
|
|
};
|
|
|
|
module.exports = nextConfig;
|