The problem definition
On my page, www.xxx.com/page, there is a script:
<script type="text/javascript" src="main.1234.js"></script>
Browser relolves it as www.xxx.com/main.1234.js instead of www.xxx.com/page/main.1234.js
More details about my setup
In fact, there are two applications running on the same server machine:
- www.xxx.com/ (app #1)
- www.xxx.com:82/ (app #2)
The page actually exists in the app #2 as www.xxx.com:82/page. If I access the page directly, then everything works as it should work (i.e. browser resolves links as expected).
But my setup is a bit more complicated. My goal is to hide app #2 from any public access, and make it available only via app #1 as www.xxx.com/page. In order to achieve that, I setup app #1 so, that if a user requests www.xxx.com/page, then app #1 under the hood performs a request to www.xxx.com:82/page of app #2 and returns received content back to the user.
From user's point of view everything should look like content of www.xxx.com:82/page resides under www.xxx.com/page. And it almost works. The only problem is that for some reason browser resolves URLs as I described under "The problem definition". How to fix it?
Additional info, hope it may help
I suppose, that an answer should be hidden in the responces. I suppose, that a cause is that the browser receives different response headers. The following are lists of headers the browser receives in each of these two cases:
- Response from app #1 (www.xxx.com/page) where browser incorrectly resolves URLs:
- Cache-Control:private
- Content-Length:775
- Content-Type:text/html;charset=UTF-8
- Date:Fri, 19 Jan 2018 11:34:40 GMT
- Expires:Thu, 01 Jan 1970 00:00:00 UTC
- Set-Cookie:zimidy-initialSessionIdHash=-226086716; Path=/
- Strict-Transport-Security:max-age=31536000 ; includeSubDomains
- X-Content-Type-Options:nosniff
- X-Frame-Options:SAMEORIGIN
- X-XSS-Protection:1; mode=block
- Response from app #2 (www.xxx.com:82/page) where browser correctly resolves URLs:
- Accept-Ranges:bytes
- Cache-Control:public, max-age=0
- Connection:keep-alive
- Date:Fri, 19 Jan 2018 11:33:16 GMT
- ETag:W/"307-1610e1964c4"
- Last-Modified:Fri, 19 Jan 2018 11:06:40 GMT
- X-Powered-By:Express