STAGING / PRODUCTION ENVIRONMENT variable

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?

3 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…

  1. easily edit/set the data source in staging
  2. 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”.

2 Likes

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

Circling back on this, I would really love the ability to do the following in the native Xano plug-in…

A) set the data source used in the staging environment (in addition to the current ability to set the data source in editor/production)

B) set the API version in the editor in addition to the staging environment (the live site can just default to use the current live API branch)

Without the above, I feel like a true versioning process is very hard with the Xano integration, and it makes me want to switch to the REST API integration, which would be a lot of work and lose the value that the native Xano plugin brings.

1 Like