use c12 in production (netlify) #2990
ayoayco
started this conversation in
Help Wanted
Replies: 1 comment 3 replies
-
Hi. Thanks for the reproduction. c12 is a build-time dependency while server handlers (routes and middleware are part of runtime) so generally it is really not the right usage of c12. I would suggest you to read the any config (via c12 or other means) using a nitro module build-time and pass it as runtime-config that will get bundled. But on why it wouldn't work in production, please note that c12 default loads from the current working directory. A netlify deployment CWD is not not/ does not include the whole git repository, but only build-output dir. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Environment
Nitro: 2.10.4 (latest)
Node: 22.12.0
Reproduction
Repo: https://github.com/ayoayco/nitro-c12-netlify-reproduction
StackBlitz: https://stackblitz.com/edit/github-aluadpqs?file=nitro.config.ts
Netlify Build: https://app.netlify.com/sites/lively-sunflower-e3c342/deploys/67817d1b9227bb0008480b85
Describe the bug
I am using c12
loadConfig
from inside a nitro middleware and it is working okay both on dev and default node-server presets; however when deployed to netlify it is not getting the configuration.My hunch is that the config file is not in the netlify build. Apologies if this is not a bug and documented somewhere, I couldn't find how to work it out.
I'm willing to work on an improvement/fix/doc for this if someone can point to a good direction
Screenshots
node-server build

dev server

netlify (prod) function

Logs
No response
Beta Was this translation helpful? Give feedback.
All reactions