Stealth CORS with Origin Reflection and Reliable Logging

This commit is contained in:
2026-02-10 22:25:12 +08:00
parent a05c88f6d5
commit 692964625d
2 changed files with 16 additions and 11 deletions

View File

@@ -3,23 +3,23 @@
}
ai-gateway.ldex.dev {
# Log all requests to stdout
log {
output stdout
}
# 1. Force CORS headers and DELETE duplicates from backend
# Stealth CORS: Reflect the requester's origin instead of using "*"
# This avoids the "*, *" duplication and looks less suspicious to Zscaler
header {
-Access-Control-Allow-Origin
-Access-Control-Allow-Methods
-Access-Control-Allow-Headers
Access-Control-Allow-Origin *
Access-Control-Allow-Origin "{header.Origin}"
Access-Control-Allow-Methods "GET, POST, OPTIONS"
Access-Control-Allow-Headers "*"
Access-Control-Expose-Headers "*"
Access-Control-Allow-Credentials "true"
# 'defer' ensures we override any headers sent by the backend
defer
}
# 2. Immediately handle OPTIONS requests
# Handle preflights immediately
@options {
method OPTIONS
}
@@ -27,6 +27,5 @@ ai-gateway.ldex.dev {
respond "" 204
}
# 3. Proxy everything else
reverse_proxy ai-gateway:8000
}