Comments (5)
packages/api doesn't have any build step.
it also doesn't run any code on it's own right? so the next app will load the envs for you.
check out create-t3-turbo where i do this:
https://github.com/t3-oss/create-t3-turbo/blob/main/apps/nextjs/package.json#L7
https://github.com/t3-oss/create-t3-turbo/blob/main/packages/auth/env.ts
https://github.com/t3-oss/create-t3-turbo/blob/main/apps/nextjs/next.config.js#L7
from t3-env.
{
"scripts": {
"with-env": "dotenv -e ../../.env --",
"build": "pnpm with-env next build"
}
}
should work
from t3-env.
Hi @juliusmarminge,
Thanks for your reply.
I'm not sure about it. packages/api
doesn't have any build step. This would work for apps/next
for sure, and I tried similar things with dotenv and dotenv-expand, but it's not solving the issue I'm describing above I think.
In none of my attempts, I was able to make env.mjs
in packages/api
to read relevant values from root .env
file.
from t3-env.
Hi again,
I followed this approach and ended up in a very weird place now. It's working as expected here, https://codesandbox.io/p/devbox/ecstatic-pascal-wxcffg and not on my local machine. I guess for the sake of this issue, we can say it's no longer an issue. But it's still weird to get two different results with the very same code. I'll keep looking if I have something else installed that causes this discrepancy.
Thanks a lot, closing the issue now.
from t3-env.
Update: eventually, i created a separate folder packages/env
and moved everything under that. Instead of using it like import { env } from @/env.mjs
i'm using it like import { env } from '@something/env
now. Next step is to split it even further and import only relevant pieces if possible.
After trying a few options, this felt like the best approach so far. Throwing it here, in case someone needs any guidance in the future.
from t3-env.
Related Issues (20)
- Vercel preset in `@t3-oss/env-nextjs` should include `NEXT_PUBLIC_VERCEL_*` variables HOT 3
- Feature Request: Support for passing zod Schema instead of object HOT 1
- Support both process.env and import.meta.env HOT 1
- Accesing server-side env from client error thrown when importing Zod types generated from Drizzle schema HOT 1
- Empty `extends` array introduces type error TS2339 HOT 1
- Can't use env in drizzle.config.ts file HOT 31
- Cannot find module '@t3-oss/env-nextjs' or its corresponding type declarations.ts(2307) for Version 0.9.2 HOT 20
- Cannot find module '@t3-oss/env-nextjs' or its corresponding type declarations HOT 3
- feat: ability to specify unique values HOT 2
- Behavior Change when `clientPrefix` is empty HOT 1
- Error: Invalid environment variables HOT 1
- type declaration missing on v0.9.2 HOT 2
- Add note that path aliases will stop working if you use jiti HOT 1
- Can't explicitly pass `clientPrefix` option using `nuxt` HOT 6
- How to augment `proccess.env` as well from `createEnv` output. HOT 2
- Question: How to use with Expo HOT 3
- Updating from 0.8.0 to 0.9.2 seems to have broken import paths HOT 2
- Error while generating production build for the web application HOT 2
- Not able to get next.config.js environment variable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from t3-env.