Problems with blazor server behind nginx

I have installed my blazoer serverside application behind a NGINX reverse proxy on a Linux Debian server, and i have got the following error:

Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMQ719NNT592", Request id "0HMQ719NNT592:00000001": An unhandled exception was thrown by the application.
System.Exception: Unable to parse the response.
at Radzen.HttpResponseMessageExtensions.ReadAsync[T](HttpResponseMessage response)
at IoServerMultiTenant.SecurityService.GetAuthenticationStateAsync() in D:\TechnoworksDev\ioservermultitenant\IoServerMultiTenant\Services\SecurityService.cs:line 127
at IoServerMultiTenant.ApplicationAuthenticationStateProvider.GetApplicationAuthenticationStateAsync() in D:\TechnoworksDev\ioservermultitenant\IoServerMultiTenant\Services\ApplicationAuthenticationStateProvider.cs:line 54
at IoServerMultiTenant.ApplicationAuthenticationStateProvider.GetAuthenticationStateAsync() in D:\TechnoworksDev\ioservermultitenant\IoServerMultiTenant\Services\ApplicationAuthenticationStateProvider.cs:line 44

With a blazor web assembly application behind the proxy everything works fine.

This is a part of the NGINX config:

server {
server_name test.domain.com;
add_header Access-Control-Allow-Origin *;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $server_name;
}

Hi @technoworks,

Could you try the following:

  1. Remove the [HttpPost] attribute from the CurrentUser method in AccountController.cs
  2. Change the request method in SecurityService.GetAuthenticationStateAsync to HttpMethod.Get
  3. Test again with this change

Also make sure your NGINX is configured to redirect http requests to https.