Before rendering my application, I am working on fetching my data. Luckily, Next.js offers a method called getStaticProps()
for this purpose.
Currently, I am utilizing the fs
module to retrieve data from a json file in my local directory.
export async function getStaticProps() {
const rawData = fs.readFileSync('./dataset/test.json');
const data = modifyData(JSON.parse(rawData));
return {
props: {
data
}
}
}
The issue arises when trying to deploy my application through Vercel because I have not pushed my raw data to the GitHub remote repository. This leads to no data being available for retrieval during deployment...
I want to keep my raw data off GitHub for security reasons.
What I am seeking is:
- the best practices for fetching data without storing it in a remote repository
If there are any key concepts or features of Next.js that I might be overlooking, please offer your suggestions and corrections.