nextjs on vercel / zeit writing to disk fs.writeFile in server.js #12429
-
I am using a custom server with nextjs to inject some serverSideProps / getInitialProps into files. What I am doing is having something on the server update a json file every minute or so and then the getServerSideProps/getInitialProps functions read the json file from disk to populate data quickly (without having to do a network request for data). Everything works great in localhost and when doing a build/running the build locally. In production / after deploying to vercel i get the error: Internal Server Error when trying to open a page. Vercel offers build logs but not any logs for the running custom server. Is this likely a problem to do with unable to write to disk in the vm's that vercel uses to deploy apps? Is there an example out there of how I can read/write to disk with a custom server in nextjs for this purpose? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
As i know, you can write to |
Beta Was this translation helpful? Give feedback.
-
As an update: Which likely means the server.js side isn't able to fs.writeFile('/tmp/mydata.json', JSON.stringify(data), ()=>{}); so my question remains the same, how can a custom server write files to disc in the vercel hosting vms? |
Beta Was this translation helpful? Give feedback.
-
It is not possible to deploy a custom server to the Vercel platform. So it is likely the file was not there since the code in the custom server is ignored. Also, please provide a repository with some code so we can have more context. |
Beta Was this translation helpful? Give feedback.
It is not possible to deploy a custom server to the Vercel platform. So it is likely the file was not there since the code in the custom server is ignored.
Also, please provide a repository with some code so we can have more context.