fullstackhero / dotnet-starter-kit

Production Grade Cloud-Ready .NET 8 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
https://fullstackhero.net/dotnet-webapi-boilerplate/
MIT License
5.04k stars 1.5k forks source link

[BUG] [V2] Blazor Docker Image ApiBaseUrl Harcoded? #986

Closed maxiar closed 3 weeks ago

maxiar commented 1 month ago

I create a docker image for blazor client app, after that I deploy in my k8s cluster, as same as docker-compose settings:

image

But when I tried to login into my blazor app, I get a unable to reach API error:

POST https://localhost:7000/api/token net::ERR_CONNECTION_REFUSED

image

The API works fine, I can look the swagger. I suspect that the docker image is not taking the ApiBaseUrl environment variable and it's using the hardcoded setting in the src\apps\blazor\client\wwwroot\appsettings.json:

{ "ApiBaseUrl": "https://localhost:7000/" }

Is it posibble?

In docker-compose all works fine, but all is in the localhost and the all urls/ports are matching correctly... Try to change the BaseApiUrl it in the blazor docker image and try to login...

Thanks.

iammukeshm commented 1 month ago

I can understand the issue. Since Blazor WASM is executed at client, there is no way for it to read the docker environment variables. One way would be to programmatically edit the value of ApiBaseUrl on the appsettings.json during the container startup. I would read the value of the docker environment variable and set it to app settings. Makes sense?

If possible can someone work on this? This would be a minor change and have to just add a couple of scripts to the Blazor docker file. Thanks.

maxiar commented 1 month ago

Don't sorry I will do the fix in the docker image generation and then make the pull request, you don't waste time on it!

Thanks!

maxiar commented 4 weeks ago

This bug can be closed when the related PR has been merged. A appsetting.json variables was added to be replaced on container startup to support replacing variables in a blazor client app. :)