a year ago
Hi!
Is it possible to create .env file instead of using system environment variables from the UI?
22 Replies
a year ago
may I ask the usecase?
In Next.js they use .env only https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
when i export it locally i'm getting
error: Missing "DATABASE_URL" inside the .env file. The value is required to connect to the PostgreSQL serverIt's irrelevant to Railway, but only asking if we can use .env files at Railway
a year ago
I assure you next does not only use .env files
It's actually medusajs, https://docs.medusajs.com/learn/advanced-development/environment-variables, but i'm getting that error, i'm sure i have it exported DATABASE_URL
a year ago
are you using a Dockerfile?
a year ago
then I would recommend fixing your project configurations so that you are not limiting yourself to .env files
This is where they load envs
const { QUOTE_MODULE } = require("./src/modules/quote");
const { loadEnv, defineConfig, Modules } = require("@medusajs/framework/utils");
loadEnv(process.env.NODE_ENV, process.cwd());
module.exports = defineConfig({
projectConfig: {
databaseUrl: process.env.DATABASE_URL,
http: {
storeCors: process.env.STORE_CORS,
adminCors: process.env.ADMIN_CORS,
authCors: process.env.AUTH_CORS,
jwtSecret: process.env.JWT_SECRET || "supersecret",
cookieSecret: process.env.COOKIE_SECRET || "supersecret",
},
},
modules: {
companyModuleService: {
resolve: "./modules/company",
},
[QUOTE_MODULE]: {
resolve: "./modules/quote",
},
[Modules.CACHE]: {
resolve: "@medusajs/medusa/cache-inmemory",
},
[Modules.WORKFLOW_ENGINE]: {
resolve: "@medusajs/medusa/workflow-engine-inmemory",
},
},
});a year ago
are you using turbo?
"setup-db": "cd ./apps/backend && npx medusa db:create --no-interactive && npx medusa db:migrate",yarn run setup-db
a year ago
have you deployed the changes after adding the variable to your Railway service
No i haven't, currently i'm looking if i can use .env file instead, because with env file envs load, using export they don't
a year ago
try using service variables please
5 months ago
I try use service variables in a MedusaJS project but the same error is still present — Missing "DATABASE_URL" inside the .env file. The value is required to connect to the PostgreSQL server
5 months ago
can you try skipping loadEnv(process.env.NODE_ENV, process.cwd()); it process.env.NODE_ENV===production ? and also can you double checkout you don't have any .env file in your repo?
fra
can you try skipping loadEnv(process.env.NODE_ENV, process.cwd()); it process.env.NODE_ENV===production ? and also can you double checkout you don't have any .env file in your repo?
3 months ago
then how can he add API keys? I want to create a project with OpenAI API keys.