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) {
|
public UrlsModel(IConfiguration configuration, IDistributedCache db) {
|
||||||
// TODO display error on page instead
|
// TODO display error on page instead
|
||||||
BaseUrl = configuration.GetValue<string>("BaseUrl") ?? throw new ApplicationException("BaseUrl not set");
|
BaseUrl = configuration.GetValue<string>("BaseUrl") ?? throw new ApplicationException("BaseUrl not set");
|
||||||
|
#if DEBUG
|
||||||
|
BaseUrl = "https://localhost/";
|
||||||
|
#else
|
||||||
BaseUrl = new Uri(BaseUrl, UriKind.Absolute).ToString();
|
BaseUrl = new Uri(BaseUrl, UriKind.Absolute).ToString();
|
||||||
|
#endif
|
||||||
Db = db;
|
Db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,13 @@
|
||||||
var user = builder.Configuration.GetSection("Account").Get<User>();
|
var user = builder.Configuration.GetSection("Account").Get<User>();
|
||||||
string? baseUrl = builder.Configuration.GetValue<string>("BaseUrl");
|
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)
|
// Check if everything is configured (right)
|
||||||
if (string.IsNullOrEmpty(baseUrl) || Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) is false)
|
if (string.IsNullOrEmpty(baseUrl) || Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) is false)
|
||||||
throw new ApplicationException(
|
throw new ApplicationException(
|
||||||
|
|
Loading…
Reference in a new issue