I have environment variables set in Railway but they are not showing available in my app
cpxx9
HOBBYOP

a year ago

I have set env variables in Railway, but in my Node app I cannot see them.

I have all the pre-made variables, as shown in the log (i console logged all process.env), but none of the Ones I added myself

/app/node_modules/passport-jwt/lib/strategy.js:45

    throw new TypeError('JwtStrategy requires a secret or key');

    ^

TypeError: JwtStrategy requires a secret or key

at new JwtStrategy (/app/node_modules/passport-jwt/lib/strategy.js:45:15)

at module.exports (/app/config/passport.js:17:5)

at Object. (/app/routes/usersRouter.js:2:30)

at Module._compile (node:internal/modules/cjs/loader:1364:14)

at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)

at Module.load (node:internal/modules/cjs/loader:1203:32)

at Module._load (node:internal/modules/cjs/loader:1019:12)

at Module.require (node:internal/modules/cjs/loader:1231:19)

at require (node:internal/modules/helpers:177:18)

at Object. (/app/routes/indexRouter.js:2:25)

Node.js v18.20.5

npm warn config production Use --omit=dev instead.

> blog-api@1.2.0 start

> node app.js

{

NPM_CONFIG_PRODUCTION: 'false',

LIBRARY_PATH: '~/.nix-profile/lib:',

RAILWAY_REPLICA_REGION: 'us-west2',

RAILWAY_REPLICA_ID: '5cb0425b-75e0-44f7-94b7-df3fa7cffaa0',

USER: 'root',

npm_config_user_agent: 'npm/10.8.2 node/v18.20.5 linux x64 workspaces/false',

CI: 'true',

HOSTNAME: '5c3653d060e6',

RAILWAY_GIT_AUTHOR: 'cpxx9',

npm_node_execpath: '/nix/store/bzi3zjxiblnf4gzfhsn2i96rl07kxi5n-nodejs-18.20.5/bin/node',

GIT_SSL_CAINFO: '/etc/ssl/certs/ca-certificates.crt',

SHLVL: '0',

LD_LIBRARY_PATH: ':/usr/lib',

npm_config_noproxy: '',

RAILWAY_GIT_BRANCH: 'main',

PORT: '8080',

RAILWAY_GIT_COMMIT_SHA: 'bbf2096246617cc05307f800cb60e14f6815a9db',

HOME: '/root',

QTDIR: '~/.nix-profile:',

RAILWAY_GIT_REPO_NAME: 'odin-blog-backend',

npm_package_json: '/app/package.json',

CPATH: '~/.nix-profile/include:',

NIXPKGS_ALLOW_BROKEN: '1',

NIX_PROFILES: '/nix/var/nix/profiles/default /root/.nix-profile',

NODE_ENV: 'production',

RAILWAY_SERVICE_NAME: 'odin-blog-backend',

BUILDKIT_DOCKERFILE_CHECK: 'skip=all',

npm_config_userconfig: '/root/.npmrc',

INIT_CWD: '/app',

View Deploy details

> ⓘ Deployment information is only viewable by project members and Railway employees.

1 Replies

a year ago

Hello,

The DATABASE_URL should not be a shared variable, I've undone this setting for you.

You also had your start command set to npx prisma migrate dev --name init this caused the migration to run but never starts the server, I've moved npx prisma migrate dev --name init into a pre-deploy command, and set your start command to node app.js

And finally, you didn't have a domain attached to the service, so I clicked Generate Domain for you.

With all these changes, your deployment is active and accepting HTTP requests!

Best,

Brody


Welcome!

Sign in to your Railway account to join the conversation.

Loading...