In my React app, I call
https://us-central1-<project-name>.cloudfunctions.net/<express-app-name>/<function-endpoint>
which is the deployed endpoint format for all my Firebase functions. When I'm using the Firebase emulator however, this changes to http://localhost:5001/<project-name>/us-central1/<express-app-name>/<function-endpoint>
. I have to manually switch this value when deploying my app. How can I avoid this?
You'll typically want to detect what environment you code is running in, and then putting in the right URL for that environment.
If you isolate this code correctly, it's usually a single if
somewhere early on in the app's lifecycle.