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:
parent
a7d11c86cc
commit
fdfaf9d0c2
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
11
Program.cs
11
Program.cs
|
@ -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.");
|
||||
|
|
Loading…
Reference in a new issue