Skip to content

fix(decoredirect): preserve path on apex redirect#23

Merged
igoramf merged 2 commits into
mainfrom
fix/decoredirect-preserve-path-on-redirect
Jun 18, 2026
Merged

fix(decoredirect): preserve path on apex redirect#23
igoramf merged 2 commits into
mainfrom
fix/decoredirect-preserve-path-on-redirect

Conversation

@igoramf

@igoramf igoramf commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • A annotation nginx.ingress.kubernetes.io/permanent-redirect estava configurada com a URL base (https://www.client.com), fazendo o nginx redirecionar sempre para a raiz — qualquer path era descartado.
  • Fix: appenda $request_uri à URL, preservando path e query string no redirect.
  • Exemplo: oscarcalcados.com.br/promocao-botashttps://www.oscarcalcados.com.br/promocao-botas

Impacto nos Ingresses existentes

Os Ingress já criados no cluster (como redirect-htmx-store) serão corrigidos automaticamente pelo operator no próximo ciclo de reconciliação — o CreateOrUpdate vai sobrescrever a annotation antiga. Para forçar a reconciliação imediata basta fazer um touch no CR:

kubectl annotate decoredirect -n deco-redirect-system --all reconcile-at="$(date)" --overwrite

Test plan

  • Testes unitários existentes atualizados e passando (14/14)
  • Deploy no cluster e validar curl -si https://oscarcalcados.com.br/promocao-botas retornando Location: https://www.oscarcalcados.com.br/promocao-botas

🤖 Generated with Claude Code


Summary by cubic

Preserves path and query string on apex redirects by switching to an NGINX server-snippet that returns <code> <to>$request_uri;. Replaces the unsupported permanent-redirect annotation that forced redirects to the root.

  • Bug Fixes

    • Replace nginx.ingress.kubernetes.io/permanent-redirect with nginx.ingress.kubernetes.io/server-snippet: return <code> <to>$request_uri;; updated controller tests.
  • Migration

    • Requires allow-snippet-annotations: true and annotations-risk-level: Critical in the NGINX Ingress Controller.
    • Existing Ingress resources will be updated on the next reconcile. To force it now: kubectl annotate decoredirect -n deco-redirect-system --all reconcile-at="$(date)" --overwrite

Written for commit 998467a. Summary will update on new commits.

Review in cubic

igoramf and others added 2 commits June 18, 2026 16:43
The permanent-redirect annotation was set to the bare target URL (e.g.
https://www.client.com), causing nginx to redirect all requests to the
root — discarding the path. Append nginx's \$request_uri variable so the
full path and query string are preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
permanent-redirect annotation does not support nginx variables — the
admission webhook rejects values containing $. Switch to server-snippet
with $request_uri so the full path and query string are preserved.

Requires allow-snippet-annotations: true and annotations-risk-level: Critical
in the nginx ingress controller config (infra_applications PRs #156, #157).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@igoramf igoramf merged commit 9ab8a5e into main Jun 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant