My Next.js site dynamically renders content files server-side on demand (ie picture a blog).
Im trying to obtain the last modified date of these data files in the filesystem by doing fs.statFIle() and stats.mtime.toLocaleDateString().This works as expected locally, in both dev and production. On the server, at build time the stats also come back as expected - but i can’t pre-renderer these pages because: reasons! When i publish the site however, all the file stats are coming back at page request time as
The file size is right, so it isn’t failing, but the dates are getting mangled somehow. As far as I can tell this is all happening on the server ,so i don’t think it’s the data objects failing to serialise between client and server? But I’m stumped. Im sure this is my fault, but I can’t see how I could do it differently… I’d be very grateful for any ideas! Many thanks.
There’s a minimal case which demonstrates the issue at
Netlify won’t execute the post-checkout hook (in case you decide to use it). If you end up doing something like my example above, you’d have to run mtimestore as a part of the build command like:
./mtimestore && npm run build
Locally, I’m using a pre-commit hook to save the lastmod to the .mtimes file.