admin管理员组

文章数量:1200423

I'm experiencing an issue with headers in AWS Application Load Balancer (ALB). While the headers are correctly set for successful responses (2XX), they're missing for error responses (4XX, 5XX), causing CORS issues in my frontend application.

Current Header Configuration

I have configured the following custom headers in my ALB: setting the correct headers policy for my ALB

HTTP Strict Transport Security (HSTS): max-age=31536000; includeSubdomains; preload Access-Control-Allow-Origin: * Access-Control-Allow-Headers: * Access-Control-Allow-Methods: HEAD, GET, POST, OPTIONS, DELETE, CONNECT, PUT, PATCH, TRACE Access-Control-Allow-Credentials: true Access-Control-Max-Age: 36000 X-Content-Type-Options: nosniff X-Frame-Options: DENY

Expected Behavior

Headers should be present in ALL responses, regardless of the HTTP status code Frontend should be able to handle error responses properly

Actual Behavior

Headers are only present in 2XX responses Headers are missing in non-2XX responses (4XX, 5XX) Frontend fails to process error responses due to CORS restrictions

Enviroment AWS Application Load Balancer Region: us-east-1

Any help or guidance would be greatly appreciated!

Question

  1. Why are Headers only appearing in 2XX responses? How can I configure the ALB to include CORS headers in all responses, including error responses or is it an error with that new feature?

2XX response:

expected headers

Non 2xx response:

Headers went response different to 200

本文标签: