Open thedavidprice opened 2 years ago
@dac09 So far, it's all working in production according to docs.
However, I am confused as to why locally I can't access value when using .env.defaults
— it was working, then I added a .env
and then I could never get it working again even after git clean and deleting .env. Needs diagnosing.
I suspect once I add TOML_ARRAY
and REDWOOD_ENV_PREFIX
to Netlify dashboard they'll be working. But wanted to start here.
This is wrong, right? DOT_ENV
should not exist, because it's neither in your toml nor prefixed with REDWOOD_ENV_
DOT_ENV
is neither 1 nor 2, so should not be available to the web side (but it should be available to the api side)
That's how I'm interpreting the docs at least
Precisely the problem I was pointing out @Tobbe - there's inconsistencies between how we're saying it should work, and how it actually does.
...in production...
The docs have always referred to production settings. Maybe not clearly enough.
Agree that the discrepancy is confusing.
~Yes, in production. yarn rw serve
is production, no? That's why I made a point of including your red "yarn rw serve" text when I used part of your screenshots.~
For yarn rw dev
I think your screenshot is correct.
Ohh, hmm, NODE_ENV
set to production
is the key here, right? I thought you used "yarn rw serve" to mean "deployed to my hosting provider". But you were running yarn rw serve
locally too, right?
Deployed to Netlify it does look like it should
To add some color here (I think this is the right place, if not apologies and will open a separate ticket), NODE_ENV
being set to production
can cause some undesirable behavior when building/deploying Storybook, specifically interaction testing (see: https://github.com/redwoodjs/example-storybook/pull/32).
If I try and manually override this env var, bad things happen. Code such as that listed below makes it so Storybook builds only sometimes work in non production environments.
Related to work on #4334 and #4461
cc @dac09
Discussion Topics
Deployment test
console.log(process.env.X)
where X = ...:Goals:
Deployed Test
Netlify Site
https://hardcore-mestorf-245ef2.netlify.app
GitHub Repo
https://github.com/redwoodjs/env-var-test
Home page: https://github.com/redwoodjs/env-var-test/blob/main/web/src/pages/HomePage/HomePage.tsx
Local Test
yarn rw dev
yarn rw serve
(after building)