Skip to content

Commit c848d88

Browse files
feature: redirect /admin to /admin/ for code-server
code-server uses relative URLs in its HTML and computes its own redirect targets based on req.originalUrl. Without a trailing slash on /admin, the browser resolves those relative URLs against /, dropping the prefix (e.g. landing on /?folder=/srv instead of /admin/?folder=/srv). Add a redirectRegex middleware that 302s the bare /admin to /admin/ before any other middleware runs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 50a587c commit c848d88

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.3
18+
version: 0.1.4
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

templates/ingressroute.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ spec:
1919
- kind: Rule
2020
match: Host(`{{ index .Values.domains 0 }}`) && PathPrefix(`/admin`)
2121
middlewares:
22+
- name: {{ $fullName }}-admin-slash
2223
- name: {{ $fullName }}-auth
2324
- name: {{ $fullName }}-strip-admin
2425
services:

templates/middleware.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ spec:
2929
---
3030
apiVersion: traefik.io/v1alpha1
3131
kind: Middleware
32+
metadata:
33+
name: {{ include "static-webhost.fullname" . }}-admin-slash
34+
labels:
35+
{{- include "static-webhost.labels" . | nindent 4 }}
36+
spec:
37+
redirectRegex:
38+
regex: ^(https?://[^/]+)/admin$
39+
replacement: ${1}/admin/
40+
permanent: false
41+
---
42+
apiVersion: traefik.io/v1alpha1
43+
kind: Middleware
3244
metadata:
3345
name: {{ include "static-webhost.fullname" . }}-strip-admin
3446
labels:

0 commit comments

Comments
 (0)