diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig
index beea97c..a55e62c 100644
--- a/Resources/views/layout.html.twig
+++ b/Resources/views/layout.html.twig
@@ -254,7 +254,7 @@
}
// prepare the api enpoint
- {% if endpoint == '' and app.request is defined and app.request.host -%}
+ {% if endpoint == '' and app.request is not null and app.request.host -%}
var endpoint = '{{ app.request.getBaseUrl() }}';
{% else -%}
var endpoint = '{{ endpoint }}';