Bird
0
0

Why might adding custom response headers in a Spring Boot app affect CORS (Cross-Origin Resource Sharing) behavior?

hard📝 Conceptual Q10 of 15
Spring Boot - Request and Response Handling
Why might adding custom response headers in a Spring Boot app affect CORS (Cross-Origin Resource Sharing) behavior?
ABecause headers are ignored in CORS requests
BBecause custom headers change the HTTP method automatically
CBecause Spring Boot disables headers by default
DBecause browsers block responses with unknown headers unless allowed by CORS policy
Step-by-Step Solution
Solution:
  1. Step 1: Understand CORS header restrictions

    Browsers enforce CORS policies that restrict which headers can be accessed by client scripts.
  2. Step 2: Recognize need to whitelist custom headers

    Custom headers must be explicitly allowed in Access-Control-Allow-Headers response header to avoid blocking.
  3. Final Answer:

    Because browsers block responses with unknown headers unless allowed by CORS policy -> Option D
  4. Quick Check:

    CORS requires allowing custom headers explicitly [OK]
Quick Trick: Allow custom headers in CORS config to avoid browser blocking [OK]
Common Mistakes:
  • Thinking custom headers change HTTP methods
  • Assuming headers are ignored in CORS
  • Believing Spring Boot disables headers by default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes