Thank you for submitting the pull request. I understand your requirement to ensure that relative paths remain valid even when reverse proxies and base paths are modified.
However, using location.href as the baseUrl may not be the best approach, as it returns the complete URL of the current page and could lead to incorrect URLs when appending additional paths.
Instead, I suggest using location.origin combined with the directory part of location.pathname as the baseUrl. This approach ensures that the relative paths point to the correct location, even in the case of reverse proxies and modified base paths. Here is an example of how you can construct the baseUrl:
// Get the directory part of location.pathname
const basePath = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);
// Construct the baseUrl
const baseUrl = location.origin + basePath;
With this baseUrl, you can concatenate other paths, ensuring that the generated URLs are correct whether accessed directly or through a reverse proxy.
Thank you for submitting the pull request. I understand your requirement to ensure that relative paths remain valid even when reverse proxies and base paths are modified.
However, using
location.href
as thebaseUrl
may not be the best approach, as it returns the complete URL of the current page and could lead to incorrect URLs when appending additional paths.Instead, I suggest using location.origin combined with the directory part of
location.pathname
as thebaseUrl
. This approach ensures that the relative paths point to the correct location, even in the case of reverse proxies and modified base paths. Here is an example of how you can construct thebaseUrl
:With this
baseUrl
, you can concatenate other paths, ensuring that the generated URLs are correct whether accessed directly or through a reverse proxy.