diff --git a/app/main.py b/app/main.py index 7b4268f..85d675d 100644 --- a/app/main.py +++ b/app/main.py @@ -15,6 +15,7 @@ from .routers.manifest import router as manifest_router from .routers.taskpane import router as taskpane_router from .routers.xlwings import router as xlwings_router +from .templates import templates # Logging logging.basicConfig(level=settings.log_level.upper()) @@ -23,6 +24,10 @@ # App app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None) +# Starlette's url_for returns fully qualified URLs causing issues if the reverse proxy +# handles TLS and the app runs on http (https://github.com/encode/starlette/issues/843) +templates.env.globals["url_for"] = app.url_path_for + # Register Converter ObjectCacheConverter.register(object, "object", "obj") diff --git a/app/templates/base.html b/app/templates/base.html index 8214bec..2bc61db 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -5,34 +5,34 @@ Task pane - + {# htmx #} {% if settings.enable_htmx %} - - - - + + + + {% endif %} - + {# Office.js #} {% if settings.public_addin_store %} {% else %} - + {% endif %} - + {# Socket.io (must come before xlwings.js) #} {% if settings.enable_socketio %} - + {% endif %} {# xlwings.js (must come before custom-function-code) #} - - - - + + + + {# Alpine.js CSP boilerplate (must come before custom JS, which must come before alpinejs library) #} {% if settings.enable_alpinejs_csp %} - + {% endif %} {# JS Config #} @@ -46,37 +46,37 @@ { "xlwingsVersion": {{ settings.xlwings_version|tojson }} } - + {# Load Custom Functions #} - + {# Bootstrap with the xlwings theme #} {% if settings.enable_bootstrap %} - - + href="{{ url_for('static', path='/vendor/bootstrap-xlwings/dist/bootstrap-xlwings.min.css') }}" /> + + {% endif %} {# Examples #} {% if settings.enable_examples %} - + {% endif %} {# Own #} - - + + {% if settings.enable_socketio %} - + {% endif %} - - - + + + {% if settings.environment == "dev" and settings.enable_socketio %} - + {% endif %} {# Alpine.js CSP build (must come after alpinejs-csp-boilerplate.js and custom code such as main.js) #} {% if settings.enable_alpinejs_csp %} - + {% endif %} {% endblock head %} {% block extra_head %}