Skip to content

[WASM][Server] Using HTTPS fails on both the server side and app side #21090

Closed

Description

@DevTKSS

Current behavior 🐛

changing the applicationUrl value to use https in launchsettings (same ports) and using the provided server project doing the same there, the build will instantly fail with the message that it failed to find the server:

Image

Expected behavior 🎯

as dotnet runtime and most api we might want to send requests to, will require the usage of antiforgery and cors, it should be the default or even possible, to use https instead of http

How to reproduce it (as minimally and precisely as possible) 🔬

create a new uno app including wasm target, server project and for example custom auth.
start it and see the notification at the top bar.

go to the uno app launchsettings and set the http to https, same for the server project

will not longer build and fail with the shown message.

Workaround 🛠️

None! does not build when setting the url to https even while our server defines app.UseHttpsRedirection()

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

No response

Uno.Sdk version (and other relevant versions) 📦

6.1.23

IDE version 🧑‍💻

17.14.9

Anything else we need to know? 💬

If our apps are only able to use http, this will make the user get notifyed that the page he is surfing on, does not support https and he shall not type in any passwords etc. now, if our app would then be configured by template already to use authentication with e.g. customauth, that very first view he will get presented, IS a Login UI. See the Problem?
By that our produced app is marked as NOT trustable.

in best case those features should get build in, so for example, this is what I would suggest to be usable gathered from multiple resources you can find linked there:

public static class SecurityServiceExtensions
{
    public static IServiceCollection AddSecurityServices(this IServiceCollection services, IConfiguration configuration)
    {

        // Etsy Authentication requires Cross-site request forgery (CSRF) protection,
        // <see href="https://developers.etsy.com/documentation/essentials/authentication#requesting-an-oauth-token"/>
        // so we need to add the Antiforgery service.
        services.AddAntiforgery(setupAction =>
        {
            setupAction.Cookie.SecurePolicy = CookieSecurePolicy.Always; // Always use HTTPS
        });

        // Add CORS service policy as needed for wasm Multi-threaded applications
        // <see href="https://github.com/dotnet/runtime/blob/main/src/mono/wasm/features.md#multi-threading"/>
        // Configuration reference:
        // <see href="https://substack.com/home/post/p-164745710"/>
        services.AddCors(options =>
        {
            var AllowedHosts = configuration["AllowedHosts"]?
                                              .ToLowerInvariant().Split(';', StringSplitOptions.RemoveEmptyEntries)
                                              ?? throw new ArgumentNullException("AllowedHosts"); ;

            string[] Methods = [
                HttpMethods.Get,
                HttpMethods.Post,
                HttpMethods.Put,
                HttpMethods.Delete,
                HttpMethods.Patch
            ];
            string[] Headers = [
                HeaderNames.ContentType,
                HeaderNames.Cookie, // Adding Cookie header to allow cookies in CORS requests, as I want to use Cookie Authentication
                HeaderNames.Authorization,
                // Adding headers referring to MDN Docs
                // <see href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS" />
                // to avoid problems with browsers like Safari or Nightly
                HeaderNames.ContentLanguage,
                HeaderNames.AcceptLanguage,
                HeaderNames.AcceptEncoding,
                // Adding Preflight request headers from samples
                // <see href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#preflighted_requests"/>
                HeaderNames.Origin,
                HeaderNames.UserAgent,
                HeaderNames.AccessControlRequestHeaders,
                HeaderNames.AccessControlRequestMethod,
                HeaderNames.Host
            ];


            options.AddPolicy("MyCorsPolicy", policy =>
            {
                policy.WithOrigins()
                .WithMethods(Methods)
                .WithHeaders(Headers)
                .DisallowCredentials() // Credentials are not required for cors requests as we use cookies
                .SetPreflightMaxAge(TimeSpan.FromMinutes(10));
            });

        });
        return services;
    }
    public static IApplicationBuilder UseSecurityServices(this IApplicationBuilder app)
    {
        app.UseCookiePolicy();
        app.UseAntiforgery();
        app.UseCors("MyCorsPolicy");
        return app;
    }
}

Additionally I would not see the Uno.Wasm.Bootstrap.Server src check for cors beeing defined, which could potentially cause also failing and problems, as it does set Headers, this might not allow.

Activity

  1. added theissue type on Jul 20, 2025
  2. added
    triage/untriaged
    difficulty/tbd
    on Jul 20, 2025
  3. jeromelaban commented on Jul 21, 2025

    @jeromelaban
    Member

    Thanks for the report.

    I'm not able to reproduce this error, though the app does not start properly because it's running with https:

    Mixed Content: The page at 'https://localhost:5001/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://[fe80::dd0d:f7d:5d62:4b8c]:50679/rc'. This request has been blocked; this endpoint must be available over WSS.
    

    This an unrelated error to what you're mentioning. I've seen this "Mixed content" error in an issue before but it's likely pasted as an image and the search can't find it.

    With regards to what you're reporting, make sure to keep discussing your original issue, not another that would make it difficult to follow.

  4. DevTKSS commented on Jul 21, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban not sure what you mean, as this issue to reproduce you can use a dotnet new unoapp -o UnoApp1 for example choose server and wasm minimal, not sure if web auth option or pwa would be needed to be included to reproduce , but beside the template provided image I did not set any images... Just modified the url and added this to a separate file loaded in the pipeline in the api🤔 I can send you the small repro project as soon as I am at home if using the described steps does still not reproduce for you 👍

  5. DevTKSS commented on Jul 21, 2025

    @DevTKSS
    ContributorAuthor

    But I would be interested to know either way, why it is a problem to serve both via https? Why can't we?

    E.g. would try to use this: https://learn.microsoft.com/de-de/aspnet/core/security/enforcing-ssl?view=aspnetcore-9.0

    But this is for me not clear to understand what I reported to them already. The advice is switching often and the use http redirection seems reading the very first paragraph to cause exceptions?🤷🤔

  6. DevTKSS commented on Jul 21, 2025

    @DevTKSS
    ContributorAuthor

    And just FYI:
    I think I did also try this without the added pipeline calls just changing the http to https to get rid of the insecure http urls and it did have this issue throwing.🤷
    The devServer which is opening up locked on exception thrown is a uno provided thing which seems to be used for... Hd?🤷 Not sure but that's why I would expect that someone could help fix that

  7. DevTKSS commented on Jul 22, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban found this here while searching for how Blazor does it and seems like they are using https as applicationUrl somehow 🤔
    Do you see how we could get this working for uno WebAssembly - Server side?

  8. jeromelaban commented on Jul 22, 2025

    @jeromelaban
    Member

    @jeromelaban found this here while searching for how Blazor does it and seems like they are using https as applicationUrl somehow 🤔

    This scenario is supported by uno at this time.

    The devServer which is opening up locked on exception thrown is a uno provided thing which seems to be used for... Hd?🤷 Not sure but that's why I would expect that someone could help fix that

    The main issue is still about #21090 (comment). Until this is fixed the app will continue crashing.

  9. changed the title [-][WASM][Server] WebAssembly should support https by default instead of build fail[/-] [+][WASM][Server] Using HTTPS fails on both the server side and app side[/+] on Jul 22, 2025
  10. DevTKSS commented on Jul 22, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban but what is that strange mixed content? the assets of the new uno app? or what? or which repro did you use? I am not sure but would not assume you used the MyManufacturerERP Repo of mine. because I am quite sure that I messed this up at the moment and possibly will need to copy paste from a new solution

  11. jeromelaban commented on Jul 22, 2025

    @jeromelaban
    Member

    @DevTKSS we'll be investigating this issue, we do not have further information to share at this time.

  12. jeromelaban commented on Jul 22, 2025

    @jeromelaban
    Member

    @jeromelaban heared you like repros? ;) Included some video material also 👍

    Thanks. In your video, at mark 36:01, the error means that insecure connections are not allowed for the site. It needs to be enabled in the browser there when on that site (https://localhost:5001) specifically. You only enabled it for http://localhost:5000.

    For the error at 27:39, this is a "networksolution" site error that has nothing to do with uno. You can skip it and continue, but in all cases, since this is a test login, it's not needed and you have to replace it for a proper login url.

  13. DevTKSS commented on Jul 23, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban what about the idea about adding the auth setup we may contacting there to our server project? Like setting the sample Provider to appsettings.json and our own server login to appsettings.development.json ?
    Like the API client is requesting the weather from our server also. To me that sounds be a great idea and would not just solve maybe that external non-uno provider having a problem if we just start our new created uno app with auth just as is and android and web like here would thrown this errors. Do you may see any options that could be possible and our server project template updated with this? Could ease some pain for the forst app start I think...

    I mean we as users may not even targeting to use that one in debug, while if that would be set in the production ones, it would be overritten by the development settings and before running this with production settings it would be reasoned that the dev could be expected to update these settings with his own domain he than may ownes 💡

  14. DevTKSS commented on Jul 23, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban and to the settings in the browser🤔 so if running the server as startup (tryed to mention it in the video) its not showing initially my app and the error caused by this missing setting, noticed yes👍 but I would miss how to set these for the https url of that while this is instantly exiting as soon as I click on the terminal link. Do you know how to set such url (manually needed maybe?) if we are NOT on this url or at least not long enough before it is instantly exiting 😅
    I would now just know how to do this for a url like you shown🤔 but this case not.
    May I ask which browser do you use? Mine looks different and it was difficulter to find the settings you had directly there.

    I did install the chrome devtools extension some while ago before but seems like it just showing up in "insect page" and not changing something on that settings menu you had

  15. jeromelaban commented on Jul 23, 2025

    @jeromelaban
    Member

    @jeromelaban what about the idea about adding the auth setup we may contacting there to our server project? Like setting the sample Provider to appsettings.json and our own server login to appsettings.development.json ?

    You're asking for a server setup in the templates and we not there yet. Existing ASP.NET Core documentation can be instead instead at this time.

    @jeromelaban and to the settings in the browser🤔 so if running the server as startup (tryed to mention it in the video) its not showing initially my app and the error caused by this missing setting, noticed yes👍 but I would miss how to set these for the https url of that while this is instantly exiting as soon as I click on the terminal link. Do you know how to set such url (manually needed maybe?) if we are NOT on this url or at least not long enough before it is instantly exiting 😅
    I would now just know how to do this for a url like you shown🤔 but this case not.
    May I ask which browser do you use? Mine looks different and it was difficulter to find the settings you had directly there.

    You have the right browser with the right options. The browser does not close when the site fails with the mixed content error, it can be changed at that time.

  16. DevTKSS commented on Jul 23, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban ah okay, so while the message box is open? thanks will check 👍

  17. DevTKSS commented on Jul 23, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban as you refer to the asp net core documentation and you mentioned before, that our Uno WebAssembly is very similar to blazor one 🤔 they are telling to use the UseWebAssemblyDebugging() Middleware, which seems in decompile, to do something with that url we see in our Launchsettings the same as theirs. As I dont know what the Uno.Wasm.Bootstrapper.Server Package or Hot Reload is doing, do you see anything that would fix the https with this or is that doing just the same as uno does? And I seen that their client wasm has no launchsettings at all 🤔 no port anywhere...

  18. DevTKSS commented on Jul 23, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban do you can tell me, what this output means?

    MONO_WASM: The version of dotnet.runtime.js 3c298d9f00936d651cc47d221762474e25277672 is different from the version of dotnet.js e36e4d1a8f8dfb08d7e3a6041459c9791d732c01!
    MONO_WASM: The version of dotnet.native.js 3c298d9f00936d651cc47d221762474e25277672  is different from the version of dotnet.js e36e4d1a8f8dfb08d7e3a6041459c9791d732c01!
    

    should I be worried about that?

  19. DevTKSS commented on Jul 23, 2025

    @DevTKSS
    ContributorAuthor

    @jeromelaban 🤔 so while my allow insecure contents setting is defintly set to true:
    image
    I am still getting that exception window 🤔 without clicking on Login to remark.
    The cookies setting has been set to allow before, but somehow did revert itself at F5 somehow to not allow (switched it back on)
    Image
    Do we need to set the advertisements to allow? (would guess no?)
    image
    on refreshing (browser suggestion) the warning is still there 🤔
    just my question: DO we expect this to be this way?

    and to check also, this here:

    Image

    is this all as we expect it to be with the https on the wasm app added like your last caption, but server as startup, OR do we need to have then just that one with http? I dont know if it causes conflicts if both applications are having same port number matching, maybe you do know this as expert? I did not found information and also do not know if our app even looks at its launchsettings, if the server is the startproject 🤔

    Or did you mean, that this issue is caused of the fact that our server from template does not have a AddCors + UseCors and same for antiforgery? Do I need to set them to not get this issues? dont know 🤔

  20. DevTKSS commented on Jul 23, 2025

    @DevTKSS
    ContributorAuthor

    well... 🤔 this here is unexpected to me:

    Image

    I did use the uno.Bootstrapper (pane above the orange list) suggested shift + alt + D and after the 2nd try (first did nothing?) I got now the "Debug?" View 🤔 but... I would have expected that would be the same as the page I pressed that Keys on? 🤔

    as reference, this here is what I see if I again select the left tab, where I was coming from:

    Image well... this last warn is new on the list... Image guessing, we dont need to enable `Enable Local Overrides` in the Chrome Dev Tools/Settings/Preferences for Hot Reload? Image

    (Moved to issue DevTKSS/DevTKSS.MyManufacturerERP#3)
    Repro will get added there most likely thats a Extensions Navigation Issue.


    Will check if after the cookies enabled and 1st time (at least one progress 🎉) that it did enter successfully the debug tab, that pop up error messagebox still shows up, because at the moment I am closing this, my IDE Debugger breaks while the entering debug mode did work fine and the app seemed not to have problems besides that strange navigation discrepancy.

    Maybe someone should tell the user, that he may not want to close the error box and instead ignore it? 😅
    @jeromelaban would you check if we need This info to be added?

  21. github-actions commented on May 3, 2026

    @github-actions
    Contributor

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests.

  22. locked as resolved and limited conversation to collaborators on May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/tbdtriage/untriaged

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions