moved httpClient baseAddress to appsettings

This commit is contained in:
Sarah Faey 2022-11-22 22:51:37 +01:00
parent 2178ff54b6
commit e72b4daf51
6 changed files with 15 additions and 3 deletions

View file

@ -40,7 +40,7 @@ namespace DiscordBot
builder.Services.AddHttpClient(Constants.HTTP_CLIENT_NAME , httpClient =>
{
httpClient.BaseAddress = new Uri("https://localhost:7216/");
httpClient.BaseAddress = new Uri(builder.Configuration["HttpClients:LiebWebsite"]);
httpClient.DefaultRequestHeaders.Add(
HeaderNames.Accept, "application/vnd.github.v3+json");

View file

@ -4,5 +4,8 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"HttpClients": {
"LiebWebsite": "https://localhost:7216/"
}
}

View file

@ -5,5 +5,8 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"HttpClients": {
"LiebWebsite": "lieb-website"
}
}

View file

@ -64,7 +64,7 @@ builder.Services.AddAuthorization(options =>
builder.Services.AddHttpClient(Constants.HttpClientName , httpClient =>
{
httpClient.BaseAddress = new Uri("http://localhost:5240/");
httpClient.BaseAddress = new Uri(builder.Configuration["HttpClients:DiscordBot"]);
// using Microsoft.Net.Http.Headers;
// The GitHub API requires two headers.

View file

@ -9,5 +9,8 @@
"AllowedHosts": "*",
"ConnectionStrings": {
"LiebContext": "Data Source=./Database/mydb.sqlite;"
},
"HttpClients": {
"DiscordBot": "http://localhost:5240/"
}
}

View file

@ -12,5 +12,8 @@
"AllowedHosts": "*",
"ConnectionStrings": {
"LiebContext": "Server=liebdb;Database=LiebContext;Uid=root;Pwd=my-secret-pw;"
},
"HttpClients": {
"DiscordBot": "discord-bot"
}
}