1
0
Fork 0
mirror of https://github.com/miawinter98/just-short-it.git synced 2024-11-22 08:19:54 +00:00

Made project runnable in debug for development

This commit is contained in:
Mia Rose Winter 2023-04-17 22:28:36 +02:00
parent a7d11c86cc
commit fdfaf9d0c2
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
2 changed files with 13 additions and 2 deletions

View file

@ -22,7 +22,11 @@ public class UrlsModel : PageModel {
public UrlsModel(IConfiguration configuration, IDistributedCache db) {
// TODO display error on page instead
BaseUrl = configuration.GetValue<string>("BaseUrl") ?? throw new ApplicationException("BaseUrl not set");
#if DEBUG
BaseUrl = "https://localhost/";
#else
BaseUrl = new Uri(BaseUrl, UriKind.Absolute).ToString();
#endif
Db = db;
}

View file

@ -11,10 +11,17 @@
var user = builder.Configuration.GetSection("Account").Get<User>();
string? baseUrl = builder.Configuration.GetValue<string>("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.");