Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error loading blazor webassembly application with modified base path and using a reverse proxy #52417

Open
1 task done
rudeGit opened this issue Nov 28, 2023 · 3 comments
Open
1 task done
Labels
area-blazor Includes: Blazor, Razor Components feature-hot-reload This issue is related to the Hot Reload feaature Pillar: Technical Debt
Milestone

Comments

@rudeGit
Copy link

rudeGit commented Nov 28, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

  1. Blazor webassembly application (without any blazor server side component) does not load the browser when base path is modified and reverse proxy is used.
  2. However it does load properly in the browser when only base path is modified but reverse proxy is NOT used.

Expected Behavior

The browser should have displayed the blazor home page when using the reverse proxy and when base path is modified, just as it did when using the localhost and the port number when only the base path is modified but reverse proxy is not used.

Steps To Reproduce

  1. Created a project with Blazor WebAssembly Standalone App template in VS 2022 (Version 17.8.1)

  2. Based on the https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/?view=aspnetcore-8.0&tabs=visual-studio#configure-the-app-base-path, I made following changes

  3. Navigated to wwwroot/index.html file and modified the tag from:

    <base href="/" />

    to

    <base href="/foo/" />

  4. Navigated to Properties/launchSettings.json changed the https element under profiles from

    "https": {
      ...
      "applicationUrl": "https://localhost:7269;http://localhost:5297",
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
to
    "https": {
      ...
      "applicationUrl": "https://localhost:7269;http://localhost:5297",
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/foo/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "commandLineArgs": "--pathbase=/foo",
      "launchUrl": "https://localhost:7269/foo",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  1. Note the changes or additions to launchUrl, commandLineArgs and inspectUri properties.

  2. The change to inspectUri property was not discussed in the above article but I figured it out based on the exception.

  3. When I ran the project in VS, browser opened with "https://localhost:7269/foo" in the address bar and the web page renders the blazor UI as expected.

  4. Now to the hard part, I used a reverse proxy (namely Caddy server) to replace the host name from "localhost:7269" to "www.example.local" after mapping the latter to the 127.0.0.1 in the host file (on windows machine) and entered "https://www.example.local/foo" in a new tab.

  5. At first, all blazor files seemed to be loading in the browser until dynamic module request (based on the browser dev tools/network option) was issued by https://www.example.local/foo/_framework/dotnet.runtime.8.0.0.14kkjimq5k.js for blazor-hotreload.js file with the path https://www.example.local/_framework/blazor-hotreload.js. Note that the file path for blazor-hotreload.js did not include the "/foo" in it while the referer file (i.e. dotnet.runtime.8.0.0.14kkjimq5k.js) includes "/foo" in it.

  6. Needless the browser showed "An unhandled error has occurred" with Reload link to reload it again. Clicking on reload button did not solve the issue.

  7. Meanwhile the web assembly project in the VS debugger showed following exception (confirming the above error assessment):

  8. Another odd thing is that the request for https://www.example.local/_framework/blazor-hotreload.js results in status code 200 while the exception is shown on the server side.

Exceptions (if any)

Server side exception is:

Error: One or more errors occurred. (TypeError: Failed to fetch dynamically imported module: https://www.example.local/_framework/blazor-hotreload.js)
    at Jn (c:\TempCode\DummySimulation\DummySPA\DummySPA\wwwroot\foo\_framework\https:\raw.githubusercontent.com\dotnet\runtime\5535e31a712343a63f5d7d796cd874e563e5ac14\src\mono\wasm\runtime\marshal-to-js.ts:349:18)
    at Ul (c:\TempCode\DummySimulation\DummySPA\DummySPA\wwwroot\foo\_framework\https:\raw.githubusercontent.com\dotnet\runtime\5535e31a712343a63f5d7d796cd874e563e5ac14\src\mono\wasm\runtime\marshal-to-js.ts:306:28)
    at wasm://wasm/00b1e8b6:wasm-function[350]:0x1faca
    at wasm://wasm/00b1e8b6:wasm-function[246]:0x1bf8b
    at wasm://wasm/00b1e8b6:wasm-function[239]:0xf172
    at wasm://wasm/00b1e8b6:wasm-function[307]:0x1e7e4
    at wasm://wasm/00b1e8b6:wasm-function[328]:0x1efda
    at wasm://wasm/00b1e8b6:wasm-function[218]:0xcfec
    at wasm://wasm/00b1e8b6:wasm-function[774]:0x440ad
    at e.<computed> (https://www.example.local/foo/_framework/dotnet.runtime.8.0.0.14kkjimq5k.js:3:214976) {superStack: {…}, stack: <accessor>, message: 'One or more errors occurred. (TypeError: Fai…xample.local/_framework/blazor-hotreload.js)', Symbol(wasm js_owned_gc_handle): 70}

.NET Version

8.0.100

Anything else?

Visual Studio 2022 (Version 17.8.1) on Windows 11

.NET SDK:
 Version:           8.0.100
 Commit:            57efcf1350
 Workload version:  8.0.100-manifests.8d38d0cc

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100\

.NET workloads installed:
 Workload version: 8.0.100-manifests.8d38d0cc
 [maui-windows]
   Installation Source: VS 17.8.34316.72
   Manifest Version:    8.0.3/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.3\WorkloadManifest.json
   Install Type:              Msi

 [maccatalyst]
   Installation Source: VS 17.8.34316.72
   Manifest Version:    17.0.8478/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.0.8478\WorkloadManifest.json
   Install Type:              Msi

 [ios]
   Installation Source: VS 17.8.34316.72
   Manifest Version:    17.0.8478/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.0.8478\WorkloadManifest.json
   Install Type:              Msi

 [android]
   Installation Source: VS 17.8.34316.72
   Manifest Version:    34.0.43/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.43\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools]
   Installation Source: VS 17.8.34316.72
   Manifest Version:    8.0.0/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.0\WorkloadManifest.json
   Install Type:              Msi


Host:
  Version:      8.0.0
  Architecture: x64
  Commit:       5535e31a71

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  5.0.406 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.203 [C:\Program Files\dotnet\sdk]
  6.0.320 [C:\Program Files\dotnet\sdk]
  6.0.417 [C:\Program Files\dotnet\sdk]
  7.0.203 [C:\Program Files\dotnet\sdk]
  8.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Nov 28, 2023
@MackinnonBuck
Copy link
Member

This might get automatically fixed depending on the approach we take to address #45213.

@rudeGit
Copy link
Author

rudeGit commented Nov 28, 2023

@MackinnonBuck Until MS fixes this issue, is there a workaround that I can employ to move forward? Any help is greatly appreciated.

@mkArtakMSFT mkArtakMSFT added the feature-hot-reload This issue is related to the Hot Reload feaature label Dec 18, 2023
@mkArtakMSFT mkArtakMSFT modified the milestones: Planning: WebUI, Backlog Dec 18, 2023
@ghost
Copy link

ghost commented Dec 18, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components feature-hot-reload This issue is related to the Hot Reload feaature Pillar: Technical Debt
Projects
None yet
Development

No branches or pull requests

5 participants
@MackinnonBuck @rudeGit @wtgodbe @mkArtakMSFT and others