Next.js Discord

Discord Forum

Vercel cant find files on serverless function

Unanswered
Japanese anchovy posted this in #help-forum
Open in Discord
Japanese anchovyOP
I am currently using Outstatic cms https://outstatic.com/ to host some content on my nextjs app. it required me to put a folder in the root of the app "root/outstatic/..." and then set up an api route of "/api/outstatic/[[...ost]]/route.ts" with a simple export const GET = OutstaticApi.GET and export const POST = OutstaticApi.POST

It worked before, but recently on production when deployed to vercel and running the serverless functions i get the error
{
  readMdMdxFiles: Error: ENOENT: no such file or directory, scandir '/var/task/outstatic/content/news'
      at Object.readdirSync (node:fs:1507:26)
      at I (/var/task/.next/server/chunks/8968.js:6:46951)
      at w (/var/task/.next/server/chunks/8968.js:6:45808)
      at B (/var/task/.next/server/chunks/8968.js:6:46318)
      at o (/var/task/.next/server/app/(web)/videos/page.js:1:6720)
      at l (/var/task/.next/server/app/(web)/videos/page.js:1:6987)
      at eh (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:134657)
      at e (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:137542)
      at ek (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:138016)
      at Array.toJSON (/var/task/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:135626) {
    errno: -2,
    code: 'ENOENT',
    syscall: 'scandir',
    path: '/var/task/outstatic/content/news'
  }
}


How do I tell vercel that these files exist?

2 Replies

Thats the neat part... you dont.
Its serverless, it has no file system