I use this code fore Dynamic Routes in my nextjs project it work fine on developer mode but not work when i published it on my server
...Object.fromEntries(fs.readdirSync('./public/assets/data/pages/').map(i => [`/ac/${i}`, { page: '/ac/[id]' } ]))
this code is in next.config.js file
if need this is the full code
const fs = require("fs");
const path = require("path");
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
distDir: "build",
trailingSlash: true,
sassOptions: {
includePaths: [path.join(__dirname, "styles")],
},
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
"/": { page: "/" },
"/ac/asrar_archived": { page: "/ac/[id]" },
"/ac/eqbal": { page: "/ac/[id]" },
"/ac/fum": { page: "/ac/[id]" },
"/ac/hakimtoos": { page: "/ac/[id]" },
...Object.fromEntries(fs.readdirSync('./public/assets/data/pages/').map(i => [`/ac/${i}`, { page: '/ac/[id]' } ]))
};
},
the manual route part of this code work fine but the dynamic part not work when published
i search for this problem but nothing found