diff --git a/README.md b/README.md index e147315bc81eec48989091e80c1c7f4bfd1173e5..df0e786f98e83341ec10df3769b7cf7317800644 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ This library contains the common elements of the Coscine api projects. Build this project by running either the build.ps1 or the build<span></span>.sh script. The project will be build and tested. +## Necessary keys + +The key "coscine/local/api/additional/url" is necessary for describing the host url. + ### Links * [Commit convention](docs/ESLintConvention.md) diff --git a/src/ApiCommons/ApplicationInformation.cs b/src/ApiCommons/ApplicationInformation.cs index e7c253592053deb049637b2a5075bd28ec06bba7..c64c7c6db473292a4e0f5a4e690ce2a9261fa949 100644 --- a/src/ApiCommons/ApplicationInformation.cs +++ b/src/ApiCommons/ApplicationInformation.cs @@ -8,6 +8,7 @@ namespace Coscine.ApiCommons { public string AppName { get; set; } = AssemblyName(); public string AppType { get; set; } = "apis"; + public string ApiUrl { get; set; } public Version Version { get; set; } = ToSemanticVersion((System.Reflection.Assembly.GetEntryAssembly() != null) ? System.Reflection.Assembly.GetEntryAssembly().GetName().Version : System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); public string DomainName { get; set; } = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName; public string HostName { get; set; } = Dns.GetHostName(); @@ -38,7 +39,7 @@ namespace Coscine.ApiCommons { $"{TraefikBackendPath}/url", $"http://{HostName}.{DomainName}:{Port}"}, { $"{TraefikBackendPath}/weight", $"{1}"}, { $"{TraefikFrontendPath}/backend", AppName}, - { $"{TraefikFrontendPath}/routes/{AppName}/rule", $"Host:{HostName}.{DomainName};PathPrefix:/{PathPrefix}"} + { $"{TraefikFrontendPath}/routes/{AppName}/rule", $"Host:{ApiUrl.Replace("https://", "")};PathPrefix:/{PathPrefix}"} }; } } diff --git a/src/ApiCommons/Configurator.cs b/src/ApiCommons/Configurator.cs index 24fb584147d9db384e212e8c8cc860bc7e4720f0..8b5cfe68f17edabc1732618455111a89217e2b8d 100644 --- a/src/ApiCommons/Configurator.cs +++ b/src/ApiCommons/Configurator.cs @@ -53,6 +53,8 @@ namespace Coscine.ApiCommons } } + applicationInformation.ApiUrl = Configuration.GetString("coscine/local/api/additional/url"); + // Traefik Configuration foreach (var kv in applicationInformation.TraefikValues.ToArray()) {