How to config environment variable in subfolder (package and app)?

15077693dHOBBY

3 months ago

I put .env in

/apps/api, /apps/web and /packages/database

https://github.com/15077693d/portfolio-monorepo/tree/main/apps/api
https://github.com/15077693d/portfolio-monorepo/tree/main/apps/web
https://github.com/15077693d/portfolio-monorepo/tree/main/packages/database

I can build successfully in local
but in railway, It cannot get the environment variable

How to config subfolder environment variable in railway?

Solved

8 Replies

3 months ago

Hello,

Set your environment mode to lose -

https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables#environment-modes

Beyond this recommendation we would not be able to assist further as the issue is with your application config and not the platform.

Best,

Brody


Status changed to Awaiting User Response railway[bot] 3 months ago


15077693dHOBBY

3 months ago

I did, it is not working.
It is working in my local environment but not in railway.
I put the env in each package and app.

How railway assign the .env to subfolder?


Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

Nothing to do with Railway, you need to follow turbo's document.


Status changed to Awaiting User Response railway[bot] 3 months ago


15077693dHOBBY

3 months ago

So I can only config the .env in Railway at root?


Status changed to Awaiting Railway Response railway[bot] 3 months ago


3 months ago

Railway has nothing to do with .env files, variables are injected directly into the environment and you need to follow turbo's docs to allow it, please read their docs.


Status changed to Awaiting User Response railway[bot] 3 months ago


15077693dHOBBY

3 months ago

Where do the .env place in railway?
at root?


Status changed to Awaiting Railway Response railway[bot] 3 months ago


brody

Railway has nothing to do with .env files, variables are injected directly into the environment and you need to follow turbo's docs to allow it, please read their docs.

3 months ago

Please see my previous message, Railway does not create .env files.


Status changed to Awaiting User Response railway[bot] 3 months ago


3 months ago

I'm going to mark this as solved to avoid any further repetition.

Please read turbo's documentation.