feat: add native subpath support via server.path_prefix#168
Open
ajinfajrian wants to merge 2 commits into
Open
feat: add native subpath support via server.path_prefix#168ajinfajrian wants to merge 2 commits into
ajinfajrian wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context & Motivation
Currently, Vigil is hardcoded to run at the root of a domain (e.g., https://status.example.com/ ). Running it under a subpath (e.g., https://example.com/status ) is not fully supported because static assets, templates, manager API endpoints, and JavaScript requests assume they own the domain root.
This PR adds native subpath support via a new optional
path_prefixconfiguration key under the[server]block.Live Demonstration
A live demonstration of this feature in action can be viewed at:
https://ajinf.my.id/status (where all routes, stylesheets, fonts, logo links, and AJAX polling calls successfully resolve under the
/statussubpath directory).Summary of Changes
path_prefixstring parameter in the [server] config block.path_prefixis configured, Actix-Web routes and MCP services are mounted under aweb::scope(&prefix). The trimmed scope root path ("") is also mapped to the main index handler to handle trailing slash normalizations correctly.config.path_prefix).• Prepended config.path_prefix to the logo, stylesheets, and javascript links in
index.tera.• Exposed
window.PATH_PREFIXto the frontend JavaScript.• Prepended
window.PATH_PREFIXto the frontend AJAX polling endpoints inindex.js./assets/...) inside common.css to relative paths (../...) so fonts and badge icons resolve correctly under any custom subpath directory.path_prefixdocumentation to config.cfg andREADME.md.Backward Compatibility
• If
path_prefixis unset or set to an empty string (the default), the behavior remains byte-for-byte identical to the current root-relative deployment setup.• Existing deployments will not notice any change.