'How can i use the file system with Next JS project deployed to Vercel?

I have a script that fetches data from an API, creates a file with the data, and store the file in my project folder. This script is using fs from node js. I can run it locally in the getStaticProps method but I can't run the code when the project is deployed.

I understand why it's happening. But I what to know maybe there are some solutions to run the code with the working filesystem on the Vercel hosting? My goal is to update this data file when the project is on a Vercel server



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source