Skip to content

docs(filters): note static() second-parameter file vs. directory pitfall#3965

Open
mvanhorn wants to merge 1 commit intozalando:masterfrom
mvanhorn:osc/2233-document-static-redirect
Open

docs(filters): note static() second-parameter file vs. directory pitfall#3965
mvanhorn wants to merge 1 commit intozalando:masterfrom
mvanhorn:osc/2233-document-static-redirect

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Issue #2233 documented a confusing redirect: setting static("/foo", "/tmp/foo/index.html") (with the second parameter pointing directly at a file named index.html) returns 301 Moved Permanently with Location: ..//. The cause is Go's http.FileServer "redirect any request ending in /index.html to the same path without the final index.html" behavior, inherited transitively by static().

The reporter asked to document this as an edge case in the filter docs. The existing Notes list near the static filter does mention the symmetric case (GET /foo/index.html redirects to /foo/) but doesn't call out that pointing the second parameter at a file - rather than its parent directory - hits the same redirect. This PR adds one bullet covering that case, with the fix (use the parent directory) inline.

No code changes; doc-only.

Closes #2233.

This contribution was developed with AI assistance (Claude Code).

@zalando-robot
Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@szuecs
Copy link
Copy Markdown
Member

szuecs commented Apr 15, 2026

@mvanhorn can you please signoff you commit ?

git commit --amend --sign-off

should do the trick

If `static()` is called with a target path that ends in `/index.html`
(rather than the parent directory), requests get a 301 redirect with a
`Location: ..//` header, inherited from Go's `http.FileServer`
"redirect any request ending in /index.html to the same path without
the final index.html" behavior.

Document the pitfall and the fix in the existing `Notes` list so users
hitting it have something to find. Issue zalando#2233.

Closes zalando#2233

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn mvanhorn force-pushed the osc/2233-document-static-redirect branch from 0160163 to c78dde0 Compare April 15, 2026 11:47
@MustafaSaber
Copy link
Copy Markdown
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doc: static() has some interesting redirect behavior in case you reference a file "index.html"

4 participants