|
|
|
@ -41,27 +41,25 @@ public class BlazorServerLookupApiRequestService : ILookupApiRequestService, ITr |
|
|
|
|
|
|
|
public async Task<string> SendAsync(string url) |
|
|
|
{ |
|
|
|
var client = HttpClientFactory.CreateClient(); |
|
|
|
var client = HttpClientFactory.CreateClient(nameof(BlazorServerLookupApiRequestService)); |
|
|
|
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); |
|
|
|
|
|
|
|
var uri = new Uri(url, UriKind.RelativeOrAbsolute); |
|
|
|
if (!uri.IsAbsoluteUri) |
|
|
|
{ |
|
|
|
var baseUrl = string.Empty; |
|
|
|
try |
|
|
|
var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultOrNullAsync("Default"); |
|
|
|
if (remoteServiceConfig != null) |
|
|
|
{ |
|
|
|
//Blazor tiered -- mode
|
|
|
|
var remoteServiceConfig = await RemoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Default"); |
|
|
|
baseUrl = remoteServiceConfig.BaseUrl; |
|
|
|
// Blazor tiered mode
|
|
|
|
var baseUrl = remoteServiceConfig.BaseUrl; |
|
|
|
client.BaseAddress = new Uri(baseUrl); |
|
|
|
AddHeaders(requestMessage); |
|
|
|
await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, |
|
|
|
requestMessage, new RemoteServiceConfiguration(baseUrl), string.Empty)); |
|
|
|
await HttpClientAuthenticator.Authenticate(new RemoteServiceHttpClientAuthenticateContext(client, requestMessage, new RemoteServiceConfiguration(baseUrl), string.Empty)); |
|
|
|
} |
|
|
|
catch (AbpException) // Blazor-Server mode.
|
|
|
|
else |
|
|
|
{ |
|
|
|
baseUrl = NavigationManager.BaseUri; |
|
|
|
client.BaseAddress = new Uri(baseUrl); |
|
|
|
// Blazor server mode
|
|
|
|
client.BaseAddress = new Uri(NavigationManager.BaseUri); |
|
|
|
foreach (var header in HttpContextAccessor.HttpContext!.Request.Headers) |
|
|
|
{ |
|
|
|
requestMessage.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()); |
|
|
|
|