Skip to content

Conversation

@spacerockzero
Copy link

Problem:

  • When frontier-react app runs locally, TARGET_ENV was set to 'beta', instead of 'local'
  • This can cause several issues, but was noticed because local apps would only see changes made to 'beta' experiments on XPRMNTL

Cause

  • Core changed how they wanted to get vars into process after proxy was initially made, making .env/process.env and the way they cascade from fs-config from server the canonical truth, rather than direct vals in fs-config

Solution

  • Remove REMOTE_ENV usage and anywhere we're getting env vars directly from fs-config
  • Remove where we were injecting them into process

Testing

  • npm linked @fs/react-scripts, made the changes
  • used an fs-cra app, ran fr env in each env flag to set up .env locally
  • tested that process.env.TARGET_ENV was 'local' in each
  • tested that default proxy routes still worked as expected
  • test that signin/signout still worked as expected

@tylergraf
Copy link

I'm down with this. I like the idea of a REMOTE_ENV, but I don't know how important it is right now. We may be able to get to it when we go to FR 2.

@redbugz
Copy link

redbugz commented Jul 16, 2019

How do I change which environment my local points to?

@spacerockzero
Copy link
Author

fr env int fr env beta fr env prod to switch environments, like we do today

@spacerockzero
Copy link
Author

the TARGET_ENV being local works, because the BASE_URL for local is beta, and will change when you fr env to another env

@spacerockzero
Copy link
Author

The issue it's solving is that I thought we were roughly getting rid of .env files for localdev when i made setupProxy the first time.
That assumption has changed, so I cleared it out, and everything works like frontier today

@spacerockzero
Copy link
Author

@redbugz I need this merged before my zion-analytics can be merged, since I need to enable an experiment config for it.
Anything stopping us from updating the default FEATURED_DEVKEY_SHARED in fs-config to HF instead of Theme-Engage? That would reduce another piece of friction in devs getting these frontier-react apps out and working right

@spacerockzero
Copy link
Author

If you're unclear how this PR works, we can have a quick meeting to demonstrate it.
The gist:
I made frontier-react proxy setup work exactly like frontier does today.
You run the env command to build an .env file pointing to your remote of choice
It sets TARGET_ENV to local like it always has.
The auth middleware already expects this, so all the REMOTE_ENV and process.env injection i did before in setupProxy could be removed.
TARGET_ENV is unimportant locally, as the BASE_URL and all the URL env vars point to the correct env already

@tylergraf tylergraf merged commit 4172319 into develop Jul 17, 2019
@tylergraf tylergraf deleted the remote-env branch July 17, 2019 20:24
@spacerockzero
Copy link
Author

awww YEAHHHHHH!!!! 🎉

@redbugz
Copy link

redbugz commented Jul 17, 2019

We will need to update the docs for proxies I think

@spacerockzero
Copy link
Author

i'll give it a look now

@spacerockzero
Copy link
Author

docs just need a small fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants