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

app.UseForwardedHeaders() does not function correctly due to resource paths being computed only once #1828

Open
OronDF343 opened this issue Jun 10, 2024 · 0 comments

Comments

@OronDF343
Copy link
Contributor

We have an existing DotVVM app, let's say its base address is https://app.org.tld/. Now we want to also access it via a proxy server, with the resulting base address being https://new.org.tld/app/. The proxy server correctly sends the header X-Forwarded-Prefix: /app. We need the app to be accessed from both base URLs.

The correct way to solve this problem in ASP.NET Core 8.0 is to use app.UseForwardedHeaders() as described in the documentation (writing custom middleware is required for previous versions). This works perfectly for routing and redirects, however resource paths rendered into the HTML do not behave as expected since the paths are only computed once.

Example 1:

  1. Restart the app
  2. The first request comes in from https://app.org.tld/, PathBase is set to /
  3. The response HTML contains correct script and style resource URLs in the format <script src="/dotvvmResource/...
  4. The next request comes in from https://new.org.tld/app/, PathBase is set to /app
  5. The response HTML still contains URLs in the format <script src="/dotvvmResource/... when they should be <script src="/app/dotvvmResource/...

Example 2:

  1. Restart the app
  2. The first request comes in from https://new.org.tld/app/, PathBase is set to /app
  3. The response HTML contains correct script and style resource URLs in the format <script src="/app/dotvvmResource/...
  4. The next request comes in from https://app.org.tld/, PathBase is set to /
  5. The response HTML still contains URLs in the format <script src="/app/dotvvmResource/... when they should be <script src="/dotvvmResource/...

When the PathBase changes, DotVVM should render updated resource URLs and not reuse the URLs from a request that had a different PathBase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant