Update caddy
parent
e292f91d81
commit
76f9e7f9b8
27
caddy
27
caddy
|
@ -18,20 +18,17 @@ yourdomain.com {
|
|||
# Handle OPTIONS preflight requests
|
||||
@preflight method OPTIONS
|
||||
|
||||
# Allow both HTTP and HTTPS origins (including localhost)
|
||||
@allowed_origins {
|
||||
origin http://localhost:3000
|
||||
origin https://localhost:3000
|
||||
origin https://*.example.com
|
||||
origin https://your-production-domain.com
|
||||
# Workaround for older Caddy versions (no 'origin' matcher)
|
||||
@cors_origin {
|
||||
header Origin ^(http://localhost:3000|https://localhost:3000|https://.*\.example\.com|https://your-production-domain\.com)$
|
||||
}
|
||||
|
||||
# CORS headers for actual requests
|
||||
header @allowed_origins Access-Control-Allow-Origin "{http.request.header.origin}"
|
||||
header @allowed_origins Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
|
||||
header @allowed_origins Access-Control-Allow-Headers "*"
|
||||
header @allowed_origins Access-Control-Allow-Credentials "true"
|
||||
header @allowed_origins Vary Origin
|
||||
header @cors_origin Access-Control-Allow-Origin "{http.request.header.origin}"
|
||||
header @cors_origin Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
|
||||
header @cors_origin Access-Control-Allow-Headers "*"
|
||||
header @cors_origin Access-Control-Allow-Credentials "true"
|
||||
header @cors_origin Vary Origin
|
||||
|
||||
# Special handling for preflight requests
|
||||
header @preflight Access-Control-Allow-Origin "{http.request.header.origin}"
|
||||
|
@ -40,13 +37,9 @@ yourdomain.com {
|
|||
header @preflight Access-Control-Max-Age "3600"
|
||||
|
||||
# Proxy to your backend
|
||||
reverse_proxy localhost:8055 {
|
||||
header_up Host {host}
|
||||
header_up X-Real-IP {remote}
|
||||
header_up X-Forwarded-Proto {scheme}
|
||||
}
|
||||
reverse_proxy localhost:8055
|
||||
|
||||
# Ensure OPTIONS requests get 204 responses
|
||||
# Respond to OPTIONS requests immediately
|
||||
respond @preflight 204
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue