diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index c08d0ad..4a85553 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -38,7 +38,7 @@ class Configuration implements ConfigurationInterface ->addDefaultsIfNotSet() ->children() ->scalarNode('enabled')->defaultTrue()->end() - ->scalarNode('endpoint')->defaultValue('/app_dev.php')->end() + ->scalarNode('endpoint')->defaultNull()->end() ->arrayNode('request_format') ->addDefaultsIfNotSet() ->children() diff --git a/Resources/config/services.jms.xml b/Resources/config/services.jms.xml index 3f4f59f..36eefc5 100644 --- a/Resources/config/services.jms.xml +++ b/Resources/config/services.jms.xml @@ -13,5 +13,5 @@ - + diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index b72af72..967c105 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -195,6 +195,10 @@ url += api_key_parameter + '=' + $('#api_key').val(); } + {% if endpoint == '' and app.request is defined and app.request.host -%} + {% set endpoint = app.request.getBaseUrl() -%} + {% endif -%} + // and trigger the API call $.ajax({ url: '{{ endpoint }}' + url,