diff --git a/Pages/Urls.cshtml.cs b/Pages/Urls.cshtml.cs index 3094a9b..8a1f4a1 100644 --- a/Pages/Urls.cshtml.cs +++ b/Pages/Urls.cshtml.cs @@ -22,7 +22,11 @@ public class UrlsModel : PageModel { public UrlsModel(IConfiguration configuration, IDistributedCache db) { // TODO display error on page instead BaseUrl = configuration.GetValue("BaseUrl") ?? throw new ApplicationException("BaseUrl not set"); +#if DEBUG + BaseUrl = "https://localhost/"; +#else BaseUrl = new Uri(BaseUrl, UriKind.Absolute).ToString(); +#endif Db = db; } diff --git a/Program.cs b/Program.cs index 42b0dba..9ae145b 100644 --- a/Program.cs +++ b/Program.cs @@ -11,10 +11,17 @@ var user = builder.Configuration.GetSection("Account").Get(); string? baseUrl = builder.Configuration.GetValue("BaseUrl"); +#if DEBUG +baseUrl = "http://localhost/"; +user = new User("test", "test"); +Console.Error.WriteLine("YOU ARE RUNNING A DEBUG BUILD WITH TEST CREDENTIALS, " + + "DO NOT UNDER ANY CIRCUMSTANCES RUN THIS IN PRODUCTION, YOU HAVE BEEN WARNED."); +#endif + // Check if everything is configured (right) if (string.IsNullOrEmpty(baseUrl) || Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) is false) - throw new ApplicationException( - "Base-URL is not set to a correct URL, please provide JSI_BaseUrl with a valid url."); + throw new ApplicationException( + "Base-URL is not set to a correct URL, please provide JSI_BaseUrl with a valid url."); if (user is null || string.IsNullOrEmpty(user.Username) || string.IsNullOrEmpty(user.Password)) throw new ApplicationException( "Credentials not set, please provide JSI_Account__Username and JSI_Account__Password.");