NuxtN
Nuxt2y ago
1 reply
bqst

Server API & CSV issue

Hey everyone,

I’m having an issue with exposing a CSV file through a server API endpoint. Here’s what I’m working with:

• CSV Location: data/products.csv
• API Endpoint: server/api/v1/products.get.ts

I’m using papaparse for parsing the CSV as follows:

const filePath = path.resolve('data/products.csv');
const fileContent = fs.readFileSync(filePath, 'utf8');
const products = Papa.parse(fileContent, { header: true }).data;
...


This setup works perfectly on my local machine. However, when I deploy it to Vercel, I get the following error:

ENOENT: no such file or directory, open '/var/task/data/products.csv'


Any ideas on what might be causing this? I think I might have misconfigured something in the deployment settings.

Thanks in advance for any help!
Was this page helpful?