Forum Discussion

rschwarz79's avatar
rschwarz79
Icon for Altocumulus rankAltocumulus
Oct 24, 2024

Uri Rewrite and relative Uri's/Links

Hello Folks,

 

I think it's more an theoretical question, but with a practical background.

 

I've the following secenario.

 

Client side is requesting "https://www.domain.com/app

Proxy performs a HTTP:uri rewrite from /app to "/"   (content on backend system is in the root directory).

That's working fine -> I'll get a Login mask and then I'll get some incomplete content back in the browser.

 

After looking the site source code I'll find a lot of "relative links"

<!DOCTYPE html>
 <html lang="en"><head><meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> 
<base href="/" />

<link href="css/rich-text/bundle.min.css" rel="stylesheet">
<link href="css/rich-text/css/dx.light.css" rel="stylesheet"> 
<link href="css/rich-text/bundle-richedit.min.css" rel="stylesheet">

<script src="_framework/blazor.webassembly.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="_content/Dsm.Blazor.Components/common.bundle.js"></script>
<script src="_content/Dsm.Blazor.Components/contextmenu.bundle.js"></script>

and so on.

 

The problem is, the browser is requesting all these links without the subdirectory /app

https://www.domain.com/css/rich-text instead of https://www.domain.com/app/css/rich-text

 

A search on the WWW says that the usage of subfolders + rewrites with relative paths should not really be a problem. Or rather, this was described as a workaround.

According to my understanding of relative links, these should simply be added to the existing browser URL during the request.

 

Do I have a problem understanding relative links here or could be the <base href="/" /> the problem (because all paths are relative to / [root path] thus removing the /app path from subsequent requests)?

 

Thanks in advance for you help.

rschwarz

  • Yes. The client (side) should do every request with "/app/URI" (so that the F5 then loadblancing because of the /app path to the correct backend node).

    I thought with relative links that should be able. Client browser is simply attaching all relative links on the base URL in the browser. At least that was always written as a suggestion for similar problems (change all absolute paths to relative paths in the application). However, this does not seem to be the solution.

     

    On the other side I can use the Stream or Rewrite Profile (this profile is modifying the base URL to <base href="/app/" /> and the content links will be requested with the leading /app path on all the mentioned requests).

     

    The question is:

    Should all links theoretically work without the rewrite profile (because these are relative links and are actually only appended to the browser URL) or is this a misconception on my part (and some others in other forums)?

     

    Thanks