Allow forcing https for frontend config URLs
This commit is contained in:
parent
c90d4da97a
commit
fe62af9d97
|
@ -9,6 +9,7 @@ KEYCLOAK_CLIENT_ID = "portal"
|
|||
KEYCLOAK_CLIENT_SECRET = "c385278e-bd2e-4f13-9937-34b0c0f44c2d"
|
||||
DEDICATED_WORKER = True
|
||||
FRONTEND_URL = "http://localhost:3001/"
|
||||
FRONTEND_HTTPS = False
|
||||
FRONTEND_DIR = None
|
||||
FRONTEND_CONFIG = None
|
||||
TILES_FILE = None # "/tiles/tiles.mbtiles"
|
||||
|
|
|
@ -26,6 +26,7 @@ DEDICATED_WORKER = True
|
|||
# The root of the frontend. Needed for redirecting after login, and for CORS.
|
||||
# Set to None if frontend is served by the API.
|
||||
FRONTEND_URL = None
|
||||
FRONTEND_HTTPS = True
|
||||
|
||||
# Where to find the compiled frontend assets (must include index.html), or None
|
||||
# to disable serving the frontend.
|
||||
|
|
|
@ -157,10 +157,11 @@ if INDEX_HTML and exists(INDEX_HTML):
|
|||
@app.get("/config.json")
|
||||
def get_frontend_config(req):
|
||||
base_path = req.server_path.replace("config.json", "")
|
||||
scheme = 'https' if req.app.config.FRONTEND_HTTPS else req.scheme
|
||||
result = {
|
||||
**req.app.config.FRONTEND_CONFIG,
|
||||
"apiUrl": f"{req.scheme}://{req.host}{base_path}api",
|
||||
"loginUrl": f"{req.scheme}://{req.host}{base_path}login",
|
||||
"apiUrl": f"{scheme}://{req.host}{base_path}api",
|
||||
"loginUrl": f"{scheme}://{req.host}{base_path}login",
|
||||
}
|
||||
print(req.app.config)
|
||||
if req.app.config.get("TILES_FILE"):
|
||||
|
|
Loading…
Reference in a new issue