

Therefore, IWebAssemblyHostEnvironment.BaseAddress ( new Uri()) is assigned to the HttpClient.BaseAddress in an app generated from the project template. AddHttpClient is an extension in Ĭlient => client.BaseAddress = new Uri(""))ī(sp => sp.GetRequiredService()įor a hosted Blazor solution based on the Blazor WebAssembly project template, request URIs are within the app's base URI by default. IHttpClientFactory.CreateClient creates and configures an HttpClient instance for outgoing requests using the configuration that corresponds to the named HttpClient ( WebAPI).Access tokens are only added when the request URI is within the app's base URI. BaseAddressAuthorizationMessageHandler is the DelegatingHandler used to process access tokens.IHttpClientFactory is provided by the NuGet package. HttpClient.BaseAddress is the base address of the resource URI when sending requests. AddHttpClient adds IHttpClientFactory and related services to the service collection and configures a named HttpClient ( WebAPI).For more information on server-side CORS configuration, see the Cross-origin resource sharing (CORS) section later in this article. In addition to the client app configuration for server API access, the server API must also allow cross-origin requests (CORS) when the client and the server don't reside at the same base address.
