Skip to content

Fix custom header is not applied for directory requests when redirect-trailing-slash is disabled#613

Merged
joseluisq merged 1 commit intomasterfrom
fix-custom-header-not-applied-no-trailing-slash
Jan 11, 2026
Merged

Fix custom header is not applied for directory requests when redirect-trailing-slash is disabled#613
joseluisq merged 1 commit intomasterfrom
fix-custom-header-not-applied-no-trailing-slash

Conversation

@joseluisq
Copy link
Collaborator

@joseluisq joseluisq commented Jan 11, 2026

Description

This PR fixes an issue where custom headers were not applied for directory requests when the redirect-trailing-slash was disabled.

Configuration

[general]
root = "./public"
port = 8080
redirect-trailing-slash = false

[advanced]
[[advanced.headers]]
source = "**/*.html"
[advanced.headers.headers]
# header to overwrite
Cache-Control = "no-cache"
# header to add
X-Custom-Header = "Server is running"

Response (before)

$ curl -LI http://localhost:8080/posts
# HTTP/1.1 200 OK
# content-length: 18
# content-type: text/html
# accept-ranges: bytes
# last-modified: Sun, 11 Jan 2026 21:19:51 GMT
# vary: accept-encoding
# cache-control: max-age=86400
# date: Sun, 11 Jan 2026 21:24:38 GMT

Response (after)

The cache-control and x-custom-header should be applied correctly.

$ curl -LI http://localhost:8080/posts
# HTTP/1.1 200 OK
# content-length: 18
# content-type: text/html
# accept-ranges: bytes
# last-modified: Sun, 11 Jan 2026 21:19:51 GMT
# vary: accept-encoding
# cache-control: no-cache
# x-custom-header: Server is running
# date: Sun, 11 Jan 2026 21:25:53 GMT

Related Issue

It fixes #612

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

@joseluisq joseluisq self-assigned this Jan 11, 2026
@joseluisq joseluisq added v2 v2 release advanced-feature Advanced feature only available via the configuration file bugfix This is PR fixes a bug labels Jan 11, 2026
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jan 11, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  src/custom_headers.rs  3% smaller

@joseluisq joseluisq changed the title Fix custom header is not applied when redirect-trailing-slash is disabled Fix custom header is not applied for directory requests when redirect-trailing-slash is disabled Jan 11, 2026
@joseluisq joseluisq marked this pull request as ready for review January 11, 2026 21:37
@joseluisq joseluisq merged commit df5fb00 into master Jan 11, 2026
32 checks passed
@joseluisq joseluisq deleted the fix-custom-header-not-applied-no-trailing-slash branch January 11, 2026 21:38
@joseluisq joseluisq added this to the v2.40.2 milestone Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

advanced-feature Advanced feature only available via the configuration file bugfix This is PR fixes a bug v2 v2 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Advanced header not applied to index.html within folders

1 participant