Skip to content

CORS blocked HotReload module when using Aspire DevTunnel with Blazor WebAssembly (dynamic import fails) #14527

Open

Description

@mahdiyar021

Summary
When running a Blazor WebAssembly app with Hot Reload behind an Aspire DevTunnel (devtunnels.ms origin), the browser blocks the HotReload runtime module loaded from due to missing CORS headers. This prevents the dynamic import of and breaks Hot Reload / app startup.

Environment
• Project type: Blazor WebAssembly (ASP.NET Core hosted) with Hot Reload enabled
• Tunnel provider: Aspire DevTunnel (domain pattern )
• Local dev server: (Kestrel / ASP.NET Core dev server)
• Browser: Chromium-based (error shown in console)
• Observed on: local development machine using dev tunnel to expose local site

Steps to reproduce

  1. Start the ASP.NET Core backend and Blazor WebAssembly app locally (listening on ) with Hot Reload enabled.
  2. Expose the local site through Aspire DevTunnel so the public origin is something like .
  3. Open the tunneled URL in a browser.
  4. Observe console errors and failed module load.

Actual behavior
Browser console shows CORS error and module load failure:

Hot Reload module is requested from while the page origin is the devtunnel domain, so the browser blocks the request because the response lacks .

Expected behavior
The Hot Reload module should load successfully when the app is accessed via the dev tunnel. Either:
• The dev server should respond with the appropriate CORS headers allowing the devtunnel origin, or
• The dev tunnel should proxy requests so the browser sees same-origin responses, or
• The Hot Reload client should request the module from the tunneled origin rather than .

Temporary workarounds
• Access the site directly via (no tunnel) to avoid cross-origin requests.
• Manually enable permissive CORS on the local dev server during development (e.g., allow or ) — note: only for local dev, not production.
• Disable Hot Reload if that avoids the dynamic import (loses Hot Reload functionality).

Suggested fixes / investigation pointers
• Ensure the dev server (Kestrel / ASP.NET Core) includes for requests coming from the devtunnel origin. This can be done by configuring CORS middleware to allow the tunnel origin(s) during development.
• Alternatively, have the dev tunnel proxy the Hot Reload static content so the browser requests the module from the same tunneled origin instead of .
• Investigate why the Hot Reload client resolves the module URL to when the page origin is the devtunnel domain; consider making the Hot Reload client use relative or tunneled URLs when behind a proxy/tunnel.
• Consider adding guidance to documentation for using Hot Reload with dev tunnels (example CORS config or recommended tunnel proxy settings).

Additional information
• This appears specific to dynamic module imports used by the Hot Reload runtime and how the runtime constructs the module URL.
• Reproducible consistently when using Aspire DevTunnel (tunneled origin differs from ).
• Console stack traces and network request details are attached above; I can provide a HAR or screenshots if helpful.

Activity

  1. added
    needs-area-label
    on Feb 17, 2026
  2. added
    area-integrations
    and removed
    needs-area-label
    on Feb 26, 2026
  3. danroth27 commented on Feb 26, 2026

    @danroth27
    Member

    Aspire + Blazor WebAssembly hot reload issue. Adding Devin Breshears (@dbreshears) Sayed Ibrahim Hashimi (@sayedihashimi).

  4. mahdiyar021 commented on Apr 28, 2026

    @mahdiyar021
    Author

    Any update ?

  5. DamianEdwards commented on Oct 20, 2026

    @DamianEdwards
    Member

    mahdiyar (@mahdiyar021) could you share a few details to help us narrow this down? Several URLs and module names appear to be missing from the issue description.

    • The full browser console error, including the failing module URL, plus the request’s status code from the Network tab. Feel free to redact your tunnel ID, but please preserve the URL’s scheme, hostname suffix, port, and path.
    • Your Aspire version, .NET SDK version (dotnet --info), and the Blazor app’s target framework.
    • How you launch the AppHost: Visual Studio (including its version), VS Code, aspire run, or dotnet watch.
    • A minimal AppHost snippet showing the Blazor project and Dev Tunnel configuration, and whether the browser is on the development machine or another device.

    We found that some hot-reload tooling connects directly to localhost rather than through the tunnel, while newer tooling can reject the tunnel’s WebSocket origin. The exact failed request will help distinguish those cases from the dynamic-module CORS failure you’re seeing.

  6. mahdiyar021 commented on Oct 20, 2026

    @mahdiyar021
    Author

    Just create an Aspire app with Blazor and ASP.NET. It won't work with DevTunnel; I tested it 3 or 4 months ago. My PC is broken right now, so I can't help with this at the moment.

  7. DamianEdwards commented on Oct 20, 2026

    @DamianEdwards
    Member

    We reproduced a Dev Tunnel hot-reload failure with .NET SDK 10.0.402 and verified that the same hosted Blazor WebAssembly scenario works through a live Dev Tunnel with .NET 11 RC2 (SDK 11.0.100-rc.2.26504.105), without additional origin configuration. The app can remain targeted at net10.0.

    .NET 11 RC2 includes the SDK fix in dotnet/sdk#56118 (backported in dotnet/sdk#56362), which routes hot-reload traffic through the application origin instead of connecting directly to localhost. No Aspire code change was needed in our repro.

    The failure we confirmed on .NET 10 was a rejected hot-reload WebSocket connection rather than the exact module-import CORS error described here, but the newer SDK resolves the tunnel scenario we tested. Please try it with .NET 11 RC2 when you are able.

  8. mahdiyar021 commented on Oct 21, 2026

    @mahdiyar021
    Author

    Any fix for dotnet 10 ?

  9. DamianEdwards commented on Oct 21, 2026

    @DamianEdwards
    Member

    mahdiyar (@mahdiyar021) not sure, that's a question for the .NET SDK & Blazor folks, but looking at it it's a pretty big change so not sure if it meets the typical servicing bar.

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

    area-integrationsblazor-wasm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions