Rapid
Rapid copied to clipboard
Make it easier to point Rapid at non-OSM API and auth provider
Description
I am working on setting up rapid for use by OpenHistoricalMap, and I found it more difficult than I expected to point my local Rapid at our OHM data and auth settings.
The context is here: https://github.com/OpenHistoricalMap/issues/issues/684#issuecomment-1931039860
I thought I would just change these settings in index.html
to point at OHM urls and credentials and have the app use those new settings.
As it stands, I changed those but then also had to change what seem like the same values in two other places:
At that point, I was loading OHM data and my local auth was failing in the same way as Rapid is with OSM (since localhost is not a valid redirect URI for the OAUTH2 credential, and cannot be since URIs for OAUTH2 must be https and localhost is not).
So this is solvable, but it seems strange to have to set these in two places, and ideally they would be easy to set via ENV vars or similar, so that we can easily maintain our own Rapid but pull in upstream changes frequently.
@danrademacher Can you mention precisely which functionality this issue is raising to ??
Well it's more like developer functionality than user functionality.
As a developer, I should have to specify API endpoint and credentials in only one place, ideally in index.html.
But when I tested that, changing those in that file had no effect and instead I had to change the instances of the default values elsewhere in the code
Thanks @danrademacher I agree that you shouldn't need to make the changes in a bunch of places.
We don't do a good job explaining the new way to set things up now that our startup process is async.
I guess my intent was that adding something like this to index.html
should work, however I see now that it probably won't because the system will already be started and firing off API calls before the then
is called.
Elsewhere we differentiate between "init" and "startup" - I think we need to do that in Context
also - to allow people to inject some customization before the components really start up.
context.initAsync()
.then(() => {
const osm = context.services.osm;
return osm.switchAsync({
url: 'https://www.openhistoricalmap.org',
apiUrl: 'https://www.openhistoricalmap.org',
client_id: 'HSNR54A1pMDYBBf2eikPkhMt0-eHL6z-E_urfND0CTE',
client_secret: 'REDACTED'
});
});