You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I set ANCHR_PUBLIC_URL="http://127.0.0.1:8080/anchr" to define my base URL root, but I'm encountering two issues:
Response URL Issue: When making requests to http://127.0.0.1:8080/anchr, the response URL redirects to http://127.0.0.1:8080/, which causes routing errors.
API and Resource Path Issue: When shortening links or uploading images, the requests go to http://127.0.0.1:8080/api instead of the expected http://127.0.0.1:8080/anchr/api. The responses also seem incorrect.
Expected Behavior
Responses should be directed to http://127.0.0.1:8080/anchr.
Requests for resources like APIs and uploaded images should follow the base URL and go to http://127.0.0.1:8080/anchr/api.
Actual Behavior
Responses are directed to http://127.0.0.1:8080/.
Resource requests ignore the base URL path, going to http://127.0.0.1:8080/api instead of http://127.0.0.1:8080/anchr/api.
Steps to Reproduce
Set ANCHR_PUBLIC_URL="http://127.0.0.1:8080/anchr".
Attempt to shorten a link or upload an image.
Observe the response URL and the API/resource request paths.
Possible Solution
Adjust the routing to ensure the response and API/resource requests respect the base URL path.
The text was updated successfully, but these errors were encountered:
There is another issue regarding the URLs for images and short links. For images, the URL is fetched from the request header; however, for short links, it retrieves the URL from ANCHR_PUBLIC_URL. This discrepancy can be observed in the image I provided. I believe it would be better to source both from a single location to avoid potential problems.
Currently, ANCHR_PUBLIC_URL is expected to be the root of the application, i.e. that path part of the URL is expected to effectively be /. A common approach to run applications under a subpath is to use a reverse proxy instead, e.g. see this example. However, Anchr doesn't support their either, currently.
I'm reluctant to add logic for running under a subpath to the application itself, as you suggested. While it would be possible to extend the role of ANCHR_PUBLIC_URL to fully customize frontend- and API URL's, it's quite uncommon, I think. I don't think I remember having seen something like that somewhere else before.
However, it would be totally legitimate to add support for running under a subpath when behind a reverse proxy. This would require to:
Dynamically set <a base href="...">
Replace all absolute API endpoint paths (/api/xyz) by relative paths (api/xyz) in the frontend
Make "Logout" button redirect to actual base path instead of /
...
I'll add this as a feature request, but - honestly - won't be getting to it too soon, unfortunately.
muety
changed the title
Issue with Base URL Configuration
Support running under subpath
Nov 2, 2024
Hi @muety
I set
ANCHR_PUBLIC_URL="http://127.0.0.1:8080/anchr"
to define my base URL root, but I'm encountering two issues:Response URL Issue: When making requests to
http://127.0.0.1:8080/anchr
, the response URL redirects tohttp://127.0.0.1:8080/
, which causes routing errors.API and Resource Path Issue: When shortening links or uploading images, the requests go to
http://127.0.0.1:8080/api
instead of the expectedhttp://127.0.0.1:8080/anchr/api
. The responses also seem incorrect.Expected Behavior
http://127.0.0.1:8080/anchr
.http://127.0.0.1:8080/anchr/api
.Actual Behavior
http://127.0.0.1:8080/
.http://127.0.0.1:8080/api
instead ofhttp://127.0.0.1:8080/anchr/api
.Steps to Reproduce
ANCHR_PUBLIC_URL="http://127.0.0.1:8080/anchr"
.Possible Solution
The text was updated successfully, but these errors were encountered: