Whatever you develop, whether it's a frontend website, backend server or anything in between or otherwise, you end up cycling between on-going development versions and publishable production versions.
I wonder what's your preferred way and why.
I will list methods on top of my head, and from comments, with pros and cons.
I even wrote tonight a small Python package called "switchto" which edits the hosts file. see it here:
https://pypi.org/project/switchto/
Environment Variables:
+easy
+CLI
-per process
-daemon pass them differently (e.g. pm2)
Different Domains:
+super easy
-code has to be environment-aware
-might require cross-origin policy (e.g. use production web with dev API, etc.)
-will not share tokens (cookies, auth, etc.)
*intranet servers inaccessible to external webhooks
Config File:
+easily stored, versioned & shared
-wrong config might leak to git
-still need to specify which config to use (via env, command line, ...)
-easy to get redundancy ("config hell")
Hosts, DNS, Proxy:
±same domain, cookies, auth tokens, etc.
+if transparent
-if not transparent
-cache WILL lie to you eventually
Browser extension:
(same as above, but I'd like to know about any extensions you know)
if I haven't mentioned anything (or you think something I said is wrong, or easily solvable) please do comment!
Mostly env parameters and secrets, because Kubernetes. Also a good best practice in general imo, see https://12factor.net/
cool, looks like a nice read. will need some time to get back to you on that one ;)
By development, you mean something like staging or testing?
Development to me means localhost, so it's a non-issue there.
For staging vs production, it's just a different subdomain.
Exactly, development, testing, staging, production.
It's a(can be) combination of things.
You need config vars/env vars to store secrets and configuration.
Your app has to be env. aware one way or another.
env variables are hard to inspect while app is running, config files are easy.
if the config file leaks to git, purge the history.
but always add git ignore records for dev confgis.
use domains that point to 127.0.0.1 or hosts file edits, but beware using localhost can sometimes not work due to browser features restrictions on localhost.