I have a route that is trying to load a .sql query to pass to the postgres driver. I am following the examples laid out here: How can I use files in Vercel Functions?
I see that in the Source tab the .sql file is present there but I keep getting ‘file not found’.
In a server route, can’t I read a sql file? or any file for that matter? Or do I need a plugin for this use case?
@anshumanb Good to know. As of now I am not writing to files but just trying to read sql files.
Tech stack is the default that comes with installing npx create-next-app@latest. The route.js file has a single GET method and it is from there that I cam calling into the database using the sql file that the postgres driver accepts.
In the deployment summary, do you mean in the ‘Static Assests’ section? I do not see it in that section. I do see in the Build Logs that the database is connected and the sql file is read (presumably to pre-render?)
Thanks for sharing additional details. Can you share the code where you read the file? (including any imports)
About deployment summary, sometimes the files are not included in static assets but still bundled in the serverless functions. I think your assumptions about Build logs is correct.
In the meantime, you can explicitly tell Next.js to include the files using outputFileTracingRoot option in the config.
I am running nextjs latest and I’m still not getting the static files. So not too sure the ‘fix’ worked in all cases. But adding outputFileTracingIncludes does the trick. Thank you!