mirror of
https://github.com/plankanban/planka.git
synced 2026-02-25 03:14:50 +03:00
[PR #1451] feat: add support for custom URL paths via BASE_URL configuration #1302
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/plankanban/planka/pull/1451
Author: @roberfi
Created: 12/7/2025
Status: 🔄 Open
Base:
master← Head:support-url-paths📝 Commits (1)
2d61502feat: add support for custom URL paths via BASE_URL configuration📊 Changes
14 files changed (+76 additions, -18 deletions)
View changed files
📝
Dockerfile(+5 -1)📝
client/src/api/http.js(+1 -1)📝
client/src/api/socket.js(+1 -1)📝
client/src/constants/Config.js(+6 -3)📝
client/src/constants/Paths.js(+8 -6)📝
client/src/utils/access-token-storage.js(+4 -2)📝
client/vite.config.js(+1 -0)➕
server/api/controllers/index/show.js(+19 -0)📝
server/api/helpers/utils/set-http-only-token-cookie.js(+1 -1)📝
server/config/custom.js(+1 -1)📝
server/config/policies.js(+1 -0)📝
server/config/routes.js(+1 -1)📝
server/config/views.js(+1 -1)➕
server/inject-config-template.sh(+26 -0)📄 Description
Summary
Fixes #1156 and #1323
This PR adds support for deploying Planka under custom URL paths by extracting the path from the
BASE_URLenvironment variable and injecting it into the client at runtime.Problem
Previously, Planka could only be deployed at the root path (
/). Users wanting to deploy it under a subpath (e.g.,/planka) behind a reverse proxy had to rebuild the Docker image with build-time environment variables, which is not feasible for users pulling pre-built images.Solution
Architecture Changes
Runtime Configuration Injection
inject-config-template.sh) that converts the Vite-builtindex.htmlinto an EJS templateindex/show) that injectsbaseUrlPathfrom server config into the templatewindow.PLANKA_CONFIGat runtimePath Handling
SERVER_BASE_URLwith runtimeBASE_PATHthroughout the clientPaths.js) to use the dynamic base pathCookie Path Fix
/) and subpath deployments'/'whenbaseUrlPathis empty to ensure valid cookie pathshttpOnlyToken) and client-side (accessToken) cookiesTechnical Details
Server changes:
server/config/custom.js: Extract and strip trailing slash fromBASE_URLpathnameserver/inject-config-template.sh: AWK script to inject EJS template into HTML (new file)server/api/controllers/index/show.js: Controller that passesbaseUrlPathto the view (new file)server/config/routes.js: Changedindexfrom direct view rendering to controller actionserver/config/views.js: Changed extension from.htmlto.ejsserver/config/policies.js: Added public access policy forindex/showcontrollerserver/api/helpers/utils/set-http-only-token-cookie.js: Added|| '/'fallback for cookie pathClient changes:
client/src/constants/Config.js: ReadBASE_PATHfromwindow.PLANKA_CONFIG.baseUrlPathat runtimeclient/src/constants/Paths.js: PrependBASE_PATHto all route definitionsclient/src/api/http.js: UseBASE_PATHinstead ofSERVER_BASE_URLfor API callsclient/src/api/socket.js: ConfigureSocket.IOpath withBASE_PATHprefixclient/src/utils/access-token-storage.js: Set proper cookie paths with fallback to'/'client/vite.config.js: Setbase: './'for relative asset pathsBuild changes:
Dockerfile: Transformindex.htmltoindex.ejstemplate during image buildTesting
Tested with the following
nginxconfiguration:And this
BASE_URLenvironment variable indocker-compose.yml:Breaking Changes
None. Existing deployments at root path continue to work without any configuration changes.
Additional note
This is my first contribution to the project. If something is wrong, missing or anyone has a better idea to implement this, please let me know and I'll adapt my changes to your needs.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.