From 9aad512d6e02a6982b17bd7e3b5a2521c60a2248 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Fri, 2 Mar 2018 15:58:09 +0100
Subject: [PATCH] deduce URL from environment, not configuration

---
 conf/manager.conf.in           | 2 --
 lib/AccountManager/App.pm      | 2 +-
 templates/web/en/home.tt2.html | 2 +-
 templates/web/fr/home.tt2.html | 2 +-
 4 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/conf/manager.conf.in b/conf/manager.conf.in
index a90cc13..2a74e31 100644
--- a/conf/manager.conf.in
+++ b/conf/manager.conf.in
@@ -2,9 +2,7 @@
 # Token validity period, in hours
 tokens_validity_period = 2
 
-
 [app]
-url = https://my.fqdn/accountmanager
 support_email = support@my.fqdn
 
 [setup]
diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index 1020ace..307e26e 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -128,7 +128,7 @@ sub respond {
     my ($self, %in) = @_;
 
     $in{data}->{app} = {
-        url           => $self->{configuration}->{app}->{url},
+        url           => $ENV{SCRIPT_NAME},
         support_email => $self->{configuration}->{app}->{support_email},
         version       => $version,
     };
diff --git a/templates/web/en/home.tt2.html b/templates/web/en/home.tt2.html
index 6c0a1e3..383425d 100644
--- a/templates/web/en/home.tt2.html
+++ b/templates/web/en/home.tt2.html
@@ -12,5 +12,5 @@ access own services.</p>
 
 <h2>Getting started</h2>
 <p>To start testing your own services, start by selecting one your are administrator for.</p>
-<p class="text-center"><a href="?action=select_sp" class="button">Get started</a></p>
+<p class="text-center"><a href="[% app.url %]?action=select_sp" class="button">Get started</a></p>
 
diff --git a/templates/web/fr/home.tt2.html b/templates/web/fr/home.tt2.html
index b8cb756..1007a7f 100644
--- a/templates/web/fr/home.tt2.html
+++ b/templates/web/fr/home.tt2.html
@@ -12,5 +12,5 @@ comptes de test ne peuvent être utilisés qu'avec ce service.</p>
 
 <h2>Commencer</h2>
 <p>Pour commencer à tester vos propres services, commencez par en sélectionner un dont vous êtes l'administrateur.</p>
-<p class="text-center"><a href="?action=select_sp" class="button">Commencer</a></p>
+<p class="text-center"><a href="[% app.url %]?action=select_sp" class="button">Commencer</a></p>
 
-- 
GitLab