Problem
My nextJS Apis have accessed some config files through the file system,
for example, the /posts folder under the project root.
import fs from "fs";
import path from "path";
const postsDirectory = path.join(process.cwd(), "posts");
const filenames = fs.readdirSync(postsDirectory); // failed in deployment
However, the folder structure has been optimized(? and is not as same as local development and local build.
So basically the /posts folder isn't there in the deployed environment.
Solution
vercel/next.js#8251 (comment)