Hi everyone,
A bit of a context: I am building an app right now and using Bubble as ‘frontend-only’. That also means I am using an external database that is only reachable through the Backend API (let’s call it ‘BAPI’).
To make a call to BAPI, I need to specify client_id and client_secret headers. I also want to have 2 different environments (one for dev/test - TEST and one for live - PROD). As I haven’t found any way to dynamically and securely pass client_id/client_secret and change host URL depending on the environment, I am using two different API Connection setups: TEST - BAPI and PROD - BAPI. I duplicate every TEST endpoint to the PROD endpoint changing the host URL.
Now the question: I have a GET /users/me endpoint on BAPI that will return profile information that is NOT stored in Bubble’s native DB (user’s name, timezone, etc.). In order to display that information in the group or fields I need to attach it to the data type somehow. The first thing to do is to use the TEST - BAPI GET /users/me endpoint as ‘Data’ and use it as the data type and data source for the group. But now how to deal with PROD - BAPI GET /users/me? It is a different data type from Bubble’s standpoint and I can not use source data from the TEST endpoint to feed the group with type of PROD endpoint and vice versa.
I could see at least two possible solution on that problem:
-
Duplicate ‘Account Group’ that shows profile’s feed and have ‘Account Group - TEST’ and ‘Account Group - PROD’ with conditions to display or not display the specific group based on ‘isn’t live version’ condition. But that would be horrific in case of any changes: I will need to duplicate all elements and rewire all expressions for each group independently.
-
Introduce a new data type ‘Account Info’ with all needed fields, and ‘owner: CurrentUser’. In that case, my endpoints will be of type ‘Action’ and not ‘Data’. Doing so I can dynamically choose in the workflow whether I need to call TEST or PROD endpoint, then just create a new ‘thing’ in DB and use ‘Display Data into Group’ which references a unified ‘Account Info’ as its datatype. Although that solution is flexible from the ‘environments’ standpoint, I am nervous about how much extra WUs such an approach could waste just for displaying data from an environment.
There could also be a third solution where I need to introduce another backend API, something like ‘Bubble Proxy API’ that will take all endpoint parameters from GET /users/me and also include ‘the env’ parameter so that the API itself will decide where to connect to PROD or TEST BAPI using that flag. That would allow me to use a single call for ‘Data’ but I am not sure if would it be a good architecture solution.
Has anyone faced similar problems? What do you think of my approaches? Please let me know!