Custom HTTP Headers with Client-Side Routing #213
-
Hi, I'm using the latest SWS via docker with a toml config file instead of env variables. SWS is serving my client-side routed (BrowserRouter style) singe page application. It does this through the I'm trying to set security headers on all client-side routed pages. I would settle for setting the headers on every fetched resource. However, no matter what is set for Why not use the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
If you want a glob pattern to apply to everything then try an asterisk surrounded by curly braces which will be used as a wildcard. In the example below, the custom header should be applied to whatever route. [advanced]
[[advanced.headers]]
source = "{*}"
# or more advanced one:
# source = "{*/,/*}"
[advanced.headers.headers]
X-Custom-Header = "some-value" |
Beta Was this translation helpful? Give feedback.
-
BTW, great that you did remind me about the obsolete |
Beta Was this translation helpful? Give feedback.
I see, if
page-fallback
is enabled then the headers are not even applied.This is definitely missing, I just fixed that with e183ea3. But in the meantime, if you are working with Docker then try to use some of the
devel
images.docker pull joseluisq/static-web-server:devel # or docker pull joseluisq/static-web-server:devel-alpine
Or if not using Docker, then try to build SWS from source or wait until the next release.