How to know if the environment is on staging and production? When I console log environment variable from browser context, they both show ‘preview’. Should they be different?
I want to use “X data source: test” header to API calls if I’m not on production. This is to send data to test database in xano. Now, what’s the easiest way to execute this?
2 Likes
I asked @Raphael a similar question in November. At that time, he mentioned that the environment variable does not indicate production environment vs staging.
(Feel free to correct me, WeWeb team)
I want to use “X data source: test” header to API calls if I’m not on production. This is to send data to test database in xano. Now, what’s the easiest way to execute this?
There is not currently a way to do this with the native Xano integration. I see this functionality as one of the last barriers to creating a proper product development system using Xano + WeWeb.
However, technically, you should be able to achieve the desired result if you create some sort of conditional logic using the domain on every collection and API call. Of course, you lose all of the value of the native Xano integration, so it’s far from ideal.
Product feedback to the WeWeb team for the Xano integration: it would be create if we could…
- easily edit/set the data source in staging
- easily edit/set the api branch source between staging, editor, and the production app
1 Like
thank you for your reply. You are right, there’s no variable for staging vs production. I used the context>browser variable. When in editor, the var value is “editor”, and when in prod/staging, the value is “preview”. That’s why I used test header when var is “editor”.
1 Like
To manage this, I have a Deployment variable that I use.
Each time before I deploy to production, I simply change the X-Data-Source to Live and the X-Branch to whatever is the latest branch in Xano.
This way, all the API endpoints are automatically updated.
1 Like