-
Notifications
You must be signed in to change notification settings - Fork 31
fix(plane-ce): https WEB_URL with TLS + Traefik trailing-slash redirects #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,5 +9,24 @@ metadata: | |
| spec: | ||
| buffering: | ||
| maxRequestBodyBytes: {{ .Values.ingress.traefik.maxRequestBodyBytes | default 5242880 }} | ||
|
|
||
| --- | ||
| {{/* | ||
| Admin/space/live SPAs use React Router basenames with a trailing slash | ||
| (e.g. /god-mode/). Without a client-visible redirect, /god-mode serves HTML | ||
| but the router refuses to match. Use a temporary (302) redirect so browsers | ||
| do not permanently cache a bad Location (e.g. with the container port). | ||
| */}} | ||
| apiVersion: traefik.io/v1alpha1 | ||
| kind: Middleware | ||
| metadata: | ||
| name: {{ .Release.Name }}-trailing-slash | ||
| labels: | ||
| {{- include "plane.commonLabels" $ | nindent 4 }} | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| redirectRegex: | ||
| # Match full request URL; keep host/scheme, add trailing slash. | ||
| regex: "^(https://[^/]+)/(god-mode|spaces|live)$" | ||
| replacement: "${1}/${2}/" | ||
|
Comment on lines
+28
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
base="${BASE_URL%/}"
for path in /god-mode /spaces /live; do
headers="$(curl -ksS -D - -o /dev/null --max-redirs 0 "$base${path}?probe=1")"
status="$(printf '%s\n' "$headers" | awk 'NR == 1 {print $2}')"
location="$(printf '%s\n' "$headers" | awk -F': ' 'tolower($1) == "location" {sub("\r$", "", $2); print $2; exit}')"
test "$status" = "302"
test "$location" = "$base${path}/?probe=1"
doneRepository: makeplane/helm-charts Length of output: 200 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
echo "== candidate files =="
git ls-files | rg '(^|/)traefik-middleware\.yaml$|traefik|middleware' || true
echo "== file excerpt =="
if [ -f charts/plane-ce/templates/traefik-middleware.yaml ]; then
cat -n charts/plane-ce/templates/traefik-middleware.yaml | sed -n '1,120p'
fi
echo "== route references =="
rg -n "god-mode|spaces|live|RedirectRegex|redirect" charts/plane-ce/templates || trueRepository: makeplane/helm-charts Length of output: 6429 🌐 Web query:
💡 Result: In Traefik, the RedirectRegex middleware performs redirection based on regex matching and replacement [1][2]. Regarding the inclusion of query strings, the behavior depends on the version and implementation details of how the redirect is handled: 1. Query String Handling: By default, the RedirectRegex middleware does not automatically append the original request's query string to the new location if the replacement URL is treated as an absolute URL [3][4]. When a redirect occurs, the final destination is determined by the replacement string provided in your configuration [1][5]. 2. Recent Improvements: Traefik has addressed issues where full URL replacements would drop the incoming query string [4]. In updated versions, logic has been introduced to carry over the original request's query string if the replacement URL does not already contain a query string [4]. 3. Implementation Notes: - Regex Capturing: The regex option is used to match and capture elements from the request URL, and the replacement option defines the new target URL [1][5]. - Variable Expansion: Use the ${1} syntax in the replacement field to reference captured groups [1][5]. When defining these in YAML, remember that certain characters might need double escaping [1][5]. - Security: Historically, there was an issue where query parameters could be incorrectly evaluated as template functions; this has been patched to ensure the middleware does not attempt to execute template logic from URL parameters [6]. If you find that your query strings are being dropped, ensure you are using a recent version of Traefik, as fixes for absolute-URL redirection parity with tools like NGINX have been implemented [4]. If the query string is not preserved automatically, you may need to explicitly include the query parameters in your regex/replacement logic or verify that your specific routing configuration allows for query string passthrough [3][4]. Citations:
Preserve query parameters in the trailing-slash redirect. The middleware regex must match 🤖 Prompt for AI AgentsSource: MCP tools |
||
| permanent: false | ||
| {{- end }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: makeplane/helm-charts
Length of output: 197
🏁 Script executed:
Repository: makeplane/helm-charts
Length of output: 9902
🏁 Script executed:
Repository: makeplane/helm-charts
Length of output: 15004
🌐 Web query:
Helm template Go template hasPrefix string function syntax hasPrefix "traefik" .Values.ingress.ingressClass💡 Result:
In Helm templates, the hasPrefix function is provided by the Sprig library [1][2]. It tests whether a string begins with a specified prefix and returns a boolean value [1][3]. Syntax The function takes two arguments: the prefix to search for, and the string to search within [1][2]. {{ hasPrefix "prefix" "your-string" }} Alternatively, it can be used in a pipeline: {{ "your-string" | hasPrefix "prefix" }} Example with.Values.ingress.ingressClass If you want to check if the ingressClass value starts with a specific string (for example, "traefik-"), you can use it in your Helm template as follows: {{- if hasPrefix "traefik-".Values.ingress.ingressClass }} # Logic to execute if it matches {{- end }} Or using the pipeline style: {{- if.Values.ingress.ingressClass | hasPrefix "traefik-" }} # Logic to execute if it matches {{- end }} Important Notes 1. Availability: Helm templates include Sprig functions by default [1]. You do not need to register them manually, unlike standard Go text/template which does not include this function natively [4][5]. 2. Traefik Context: While Traefik configuration often deals with ingressClass, ensure that the variable you are checking (.Values.ingress.ingressClass) is defined and of type string to avoid template execution errors [6][7]. If the value might be nil or empty, you may want to provide a default value: {{- if.Values.ingress.ingressClass | default "" | hasPrefix "traefik-" }}
Citations:
Gate HTTPS inference on chart-supported TLS/ingress.
charts/plane-ce/templates/config-secrets/app-env.yamlcan emitWEB_URL: "https://..."when.Values.ingress.enabled=falseand either.Values.ssl.tls_secret_nameis set or.Values.ingress.ingressClassstarts withtraefik. Onlycharts/plane-ce/templates/ingress-traefik.yamland the standard ingress use.Values.ingress.enabled, so an external ingress can receive a chart-generated HTTPS URL for a non-chart endpoint.Require
.Values.ingress.enabledor setenv.web_urlexplicitly for external HTTPS routes.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents