Test vs Production - dynamic URL's
Options
Riaan Backer
Member ✭
Hi Xano Team
I am aware of the Data Source configuration to switch between test and production by adding a header X-Data-Source: test for API calls.
On my front end I am also running two separate environments and therefore require to send dynamic links (one for test and one for prod) for features like magiclink depending if you are using the test environment of production.
So in essence when you are in the test environment the maglink url will be different than the production environment.
Can you please confirm what would be the best option in Xano to achieve this? My thinking is to extract header information on an api level to see if the the header contains a X-Data-Source: test, and then send a different url?
It would be nice to have this taken care of behind the scenes in Xano and we only have to create a new system variable that distinct between test and production.
Please advice if my thinking is correct or would you suggest another solution
I am aware of the Data Source configuration to switch between test and production by adding a header X-Data-Source: test for API calls.
On my front end I am also running two separate environments and therefore require to send dynamic links (one for test and one for prod) for features like magiclink depending if you are using the test environment of production.
So in essence when you are in the test environment the maglink url will be different than the production environment.
Can you please confirm what would be the best option in Xano to achieve this? My thinking is to extract header information on an api level to see if the the header contains a X-Data-Source: test, and then send a different url?
It would be nice to have this taken care of behind the scenes in Xano and we only have to create a new system variable that distinct between test and production.
Please advice if my thinking is correct or would you suggest another solution
Comments
-
Hi
Since the frontend is responsible for sending the API request to Xano, then you just need a variable that you can interpret to send the appropriate header to Xano.
So if your frontend url was this for example,
https://example.com/auth?magic=123abc&env=test
Then you could send the x-data-source header if env = test -
- my question is not around on how to send the data to Xano. Let me try again. When the API call is received by Xano, which filter/function can I use to check if the header contains the x-data-source header? In my specific use case, when I receive this parameter in Xano, I will need to send a different redirect url to the front end in order to be redirected to either the test or prod environment.
-
Ah yes. There is an env variable. https://docs.xano.com/working-with-data/variables#http_headers
That's an object so you can just do dot notation on it to get the value of the header you want. -
great thanks
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback