Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to pass environment variables to Blazor WASM in hybrid Blazor app using .NET 8 and Aspire

$
0
0

I have a .NET 8 solution consisting of:

  • An ASP.NET Core 8 Web API with controllers
  • A Blazor application (.NET 8 with interactive rendering in auto mode, so there's a Blazor Server assembly and a Blazor WASM assembly)
  • .NET Aspire AppHost

In the AppHost, I am passing environment variables to the API and Blazor projects in local development using .WithEnvironment().

One of the environment variables I pass to the Blazor app is the API's "Base URL". This is needed to configure the HttpClient in the WASM assembly.

The issue I have is that the WASM assembly doesn't seem to be able to see the environment variables being passed to the Blazor project by Aspire.

How can I pass the environment variables from my Blazor server app to the Blazor WASM client app that is created along side it and that the Blazor server app references?


Viewing all articles
Browse latest Browse all 4839

Trending Articles