Add configurable default basename so app can run under /glpi/ #192
ramdaniAli
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
We would like the app to be accessible at a sub-path like
https://example.com/glpi/
(instead of only/
).Request: make the router / build base path configurable via an environment variable (e.g.
APP_BASENAME
/REACT_APP_BASENAME
) so deployments behind a path prefix such as/glpi/
are supported.Motivation
/glpi/
→http://127.0.0.1:8081/
. Currently the app assumes it runs at/
and emits root-relative links and cookies, causing redirects and 404s when served under/glpi/
.basename
makes it possible to host the app under a path prefix without requiring hacks like HTML response text rewriting in nginx (sub_filter
), which is brittle.example.com/client
,example.com/installer
,example.com/glpi
) and is a common production need.Proposed solution
APP_BASENAME
, fallback"/"
).basename
(so internal routes work), andbase
/ public URL for static assets (so CSS/JS assets load correctly).Set-Cookie
path generation and redirects are compatible (cookie path/
vsAPP_BASENAME
).Example implementations (pick the one matching the stack)
React (React Router v6) — runtime router basename
Create React App — ensure correct asset paths on build
PUBLIC_URL
(or sethomepage
in package.json) at build time:# build for /glpi/ REACT_APP_BASENAME=/glpi/ PUBLIC_URL=/glpi/ npm run build
or set
homepage
inpackage.json
:Vite — base config
Next.js — basePath
Angular
--base-href=/glpi/
tong build
and setAPP_BASE_HREF
provider if needed.Deployment / nginx notes
If you proxy
/glpi/
to the app root, ensure nginx rewritesLocation
headers and cookie paths if the backend or app emits root-relative values. The ideal approach is for the app to generate correct roots so nginx does not needsub_filter
.Backwards compatibility
/
(no breaking change).docs/deploy.md
.Tests & acceptance criteria
APP_BASENAME
is unset or/
.APP_BASENAME=/glpi/
: page assets (css/js/images) load from/glpi/...
./glpi/
./
and cookies path scoped correctly).Request
Could maintainers:
APP_BASENAME
(or an equivalent approach you prefer),Thanks!
Beta Was this translation helpful? Give feedback.
All reactions