Blazor WebAssembly login authentication/login from .well-known/openid-configuration gives localhost URL instead of public URL

The autogenerated oidc configuration file gives localhost instead of my public URL. How do I set it up so that it gives the right URL?

In the login link on my test site: the login redirects to a localhost address instead of the public address, like this:


How do I configure it so that it goes to instead?

This is the content of the authentication razor file:

@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />

    [Parameter] public string Action { get; set; }

There is no option to provide the server URL.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Your application is not configured properly.

You need to configure your identity sever using similar code like below in your Program.cs

builder.Services.AddOidcAuthentication(options =>
            builder.Configuration.Bind("OidcConfiguration", options.ProviderOptions);

“OidcConfiguration” comes from your configuration file and will have parameters like below:
"OidcConfiguration": {
    "Authority": "https://YourIdentityServerIP",
    "ClientId": "YourClienId",
    "DefaultScopes": [
    "RedirectUri": "https://yourclientapp/authentication/login-callback",
    "PostLogoutRedirectUri": "https://yourclientapp/authentication/logout-callback",
    "ResponseType": "code"


You can use this two links to see how i configured mine in a pet project

Program Files:


Method 2

The solution was to add the following:

using IdentityServer4.Extensions;

app.Use((ctx, next) => 
    return next();

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x