NuxtN
Nuxt3y ago
cosbgn

How to use static `files` with server functions?

I have a /server/api/foo.js functions which does something like this:

export default defineEventHandler(async (event) => {
    const db = JSON.parse(readFileSync(new URL(`../../server/files/colors.json`, import.meta.url), 'utf8'))


This works with nuxt dev but when I deploy to vercel it can't find the file. Where should I put it? Is there something like ~assets for back-end functions?

P.s. the file is readonly, I know vercel can't write anything since it's serverless. But I would still be able to read it.
Was this page helpful?