Tehren (Ben)
Tehren (Ben)
KKinde
Created by Asad Malik on 11/2/2024 in #💻┃support
NUXT. Vue. Error 500 while accessing /api/login, while it works fine when running dev server.
I just ran into this issue myself, the .env file is not loaded in production: "In production runtime, you should use platform environment variables and .env is not used." https://nuxt.com/docs/api/composables/use-runtime-config#using-the-env-file. So either set the environment variables in whatever platform you are using to run the app, or tell Node to load the .env file as part of the startup command, eg: "node --env-file=.env .output/server/index.mjs". The --env-file flag requires node ^20.6.0. ( I know, using .env files in production is discourage etc etc).
6 replies