Update CORS handling in Traefik and Caddy configurations

- Add origin-specific CORS settings to Traefik for `truckwash.io` with credentials support.
- Simplify and standardize CORS headers in Caddy, removing upstream duplication and adjusting preflight logic.
This commit is contained in:
Jeppe Bundgaard
2026-02-16 13:08:38 +01:00
parent 22790705b4
commit dd33fa2b19
2 changed files with 18 additions and 8 deletions
+4 -8
View File
@@ -7,11 +7,8 @@
encode gzip
root * /var/www/html
# CORS: allow all origins with literal '*' (no credentials)
@cors_origin header_regexp Origin .+
@options method OPTIONS
header @cors_origin {
# Global CORS headers: allow all origins and headers (no credentials)
header {
# Ensure no duplicate CORS headers from upstream app
-Access-Control-Allow-Origin
-Access-Control-Allow-Credentials
@@ -25,9 +22,8 @@
}
# Preflight fast-path
respond @options 204 {
header @cors_origin
}
@options method OPTIONS
respond @options 204
# PHP handling via FastCGI to php-fpm pool
php_fastcgi php1:9000 php2:9000 php3:9000 php4:9000 php5:9000
+14
View File
@@ -45,6 +45,20 @@ http:
customFrameOptionsValue: "SAMEORIGIN"
permissionsPolicy: "geolocation=(), microphone=(), camera=(), payment=()"
addVaryHeader: true
# CORS: allow all origins (with credentials). Attach this middleware where needed.
accessControlAllowOriginList:
- "https://truckwash.io"
accessControlAllowMethods:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
accessControlAllowHeaders:
- "*"
accessControlAllowCredentials: true
accessControlMaxAge: 86400
api-ratelimit:
rateLimit:
average: 100