Closed alethiophile closed 1 month ago
The updates to the Javascript frontend and the test suite are now complete. My local testing shows this is working.
To use the feature, configure your reverse proxy appropriately, then set the variable base_url_path
in lrr.conf
. The base_url_path
value is an empty string by default; this maintains the old behavior. If it is set, it must be a valid URL path fragment, beginning with a slash but with no trailing slash.
It also remains to update the documentation, since this is a user-visible feature.
Regarding documentation, I'm happy to write a docs update. However, I can't immediately find where the documentation source is. Is it hiding in some subdirectory I'm missing?
The docs are hidden in https://github.com/Difegue/LANraragi/tree/dev/tools/Documentation -- Rest of the PR looks good to me as-is.
I've added some docs. I put it alongside the reverse proxy configuration, since it's tied in with that system and that's where I looked when I was trying to find this a few weeks ago.
Makes sense to me. Docs looks good, I'll be merging this.
Thanks again!
Congratulations @alethiophile, the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cm0060y0803220clb1p38dtoy
This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!
This is toward adding a base URL feature, as discussed in https://github.com/Difegue/LANraragi/issues/363.
This works as follows: you can configure a reverse proxy server to forward traffic to LANraragi only under a given path. The proxy must be configured to strip the path prefix from the forwarded requests (e.g. in Caddy this is the
handle_path
directive, as opposed tohandle
). Once this is configured, LANraragi can be viewed as usual using subdirectories of that path. E.g. if a top-level deployment had the URLmanga.example.com
, a subdirectory deployment might have the URLexample.com/manga
. LANraragi can be used as normal, with all its internal URLs rewritten to be under the/manga
subdirectory.Internally, this works as follows: the reverse proxy strips the path prefix from requests as they pass through. Thus, LANraragi still sees ordinary requests to
/api
,/js
, etc. However, all internal links generated by LANraragi are generated relative to the new path prefix. The user will click a link to/manga/reader
, which will be processed into/reader
by the reverse proxy. The main server-side system for this is the Mojourl_for
helper (https://docs.mojolicious.org/Mojolicious/Controller#url_for).url_for
constructs URLs relative to the incoming request URL'sbase
member. Thus, when a base URL is configured, thebefore_dispatch
hook alters the URL base to include that path prefix. This makes all URLs generated viaurl_for
include it.For the Javascript frontend, the base URL will be passed to the frontend via code in the template. Then, if configured, all API calls will be rewritten to include the base URL. This is not yet finished as I submit this draft.