If I use the Private URL from the example, the system will manage the second token (‘4ZYKZOBG34CIZNQVCYFMOI2B’). But I want to manage this token from within the application itself. I want to have the app issue this token and have it associated with a specific tenant. Then I want to some method, routing method?, to move from form to form as the user uses the app.
Several Anvil App Routing experts frequent this Forum (alas, I’m not one of them), so there’s a good chance you’ll have some answers and/or questions soon.
For example you could create a route @anvil.server.route("/tenant/:tenant_id"), so when a user goes to your.domain.com/tenant/abc, you can show the correct form.
The Tenants table should have the tenant_id column.
I don’t have the foggiest idea about how to programatically make environments (which is what you’re asking for with the issue of the tokens), but here’s another way you could handle the routing when you do have the environments setup:
Basically, I just made a function pointing to the base route and then extracted the env token with the anvil.server.app_origin() string and routed based on that using a dict.
Environments are intended to be used with apps that are similar enough to be the same app and different enough to require some manual editing. For example two environments could have different CSS, or different logic. Each environment is like a customization of the app, where creating a new environment takes s few seconds and editing the differences takes much longer.
But when you are talking about the code generating environments, then you don’t need environments.
WOW thank you all for your comments and suggestions!
Here is what I am trying to do. I am building a multi-tenant app that is able to be white-labeled. That white-label requirements will require the app to have different colors and icons, etc for each tenant. In addition, I want the users to be able to self register for the application.
So after reading the docs I figured that if a token was passed as part of the URL, I could use this as a method of determining the tenant ID. In addition, since the token is basically a random string, I would offer great tenant isolation, rather than using a serial number, which someone could guess.
Since each tenant would have a distinct URL, auto registration would assign users to the correct tenant.