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
![Screenshot from 2025-01-10 21-04-03](https://private-user-images.githubusercontent.com/4262489/402139694-4bd6571a-f1c3-4b29-9e4f-a2055c2428bc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTkzNzgsIm5iZiI6MTczOTM1OTA3OCwicGF0aCI6Ii80MjYyNDg5LzQwMjEzOTY5NC00YmQ2NTcxYS1mMWMzLTRiMjktOWU0Zi1hMjA1NWMyNDI4YmMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMTExNzU4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTk4YzAwZmUwZjdiZGQ5ZDUwYzU3YTdhN2FiZTU2ZmEwYTU0MTU1YzNjZjkyNDAzNDBmYTQ2YzQwZmVhYmM1ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.am2bFka2U-MN9priD3ebMSHo09rXtwJrHrR_vVV6y30)
dev server
![Screenshot from 2025-01-10 21-04-28](https://private-user-images.githubusercontent.com/4262489/402139730-697708ed-d32a-4640-97a0-c59dce23ef9f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTkzNzgsIm5iZiI6MTczOTM1OTA3OCwicGF0aCI6Ii80MjYyNDg5LzQwMjEzOTczMC02OTc3MDhlZC1kMzJhLTQ2NDAtOTdhMC1jNTlkY2UyM2VmOWYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMTExNzU4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjAzMDEyMTY5YTAwZjA5M2QwZjViYmQxOWZhMDU4ZTJhMmM3OTQ1ODYxNzAxZDdiZmJmYjExY2ZjMmZiNmMwMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.T-nhgbkqliqZoElRMcdcSuVXCtV4kIfqLRD7z5eceeA)
netlify (prod) function
![Screenshot from 2025-01-10 21-06-54](https://private-user-images.githubusercontent.com/4262489/402139818-f690465e-3263-46e8-bd91-30ece5634f53.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTkzNzgsIm5iZiI6MTczOTM1OTA3OCwicGF0aCI6Ii80MjYyNDg5LzQwMjEzOTgxOC1mNjkwNDY1ZS0zMjYzLTQ2ZTgtYmQ5MS0zMGVjZTU2MzRmNTMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMTExNzU4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDA5ZDFkZDdhMmM1ODIwYjk0NWQxNDM3YzhlNjc3ZDFiOWM5Yjk2YWY5MzMyZWViMGMwZjE2ZDI4Yjc1MDQ0MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.CTzNHX3PXsEaqKJam3LqcnWLMW_rYOzu2EJTFnFZ_tk)
Logs
No response
Beta Was this translation helpful? Give feedback.
All reactions