llmstory
CORS and Same-Origin Policy Explanation with Server-Side Fixes
1.

Define the Same-Origin Policy (SOP) and explain its primary significance in web security.

2.

Which of the following pairs represents a 'same origin' scenario?

Select one option
3.

Which of the following pairs represents a 'cross-origin' scenario?

Select one option
4.

Explain why Cross-Origin Resource Sharing (CORS) was introduced and how it works as a security mechanism to relax the Same-Origin Policy.

5.

Describe the role of preflight requests in CORS. What HTTP method is typically used for a preflight request, and what information does it convey?

6.

Explain the purpose of the Access-Control-Allow-Origin header and provide an example value that would allow a frontend application running on http://localhost:3000 to access an API.

7.

Explain the purpose of the Access-Control-Allow-Methods header and provide an example value to permit GET and POST requests from a cross-origin frontend.

8.

Explain the purpose of the Access-Control-Allow-Headers header and provide an example value to allow custom headers X-Auth-Token and Content-Type.

9.

Explain the purpose of the Access-Control-Expose-Headers header and provide an example value to make X-Custom-Header accessible to a frontend script.

10.

Explain the purpose of the Access-Control-Max-Age header and provide an example value to cache preflight results for 10 minutes.

11.

Explain the purpose of the Vary header in the context of CORS and provide an example value.

12.

Explain why Access-Control-Allow-Origin: * should generally be avoided in production environments and what security risks it poses.

13.

Describe the best practice for setting the Access-Control-Allow-Origin header in production environments, especially when dealing with multiple legitimate origins.

Copyright © 2025 llmstory.comPrivacy PolicyTerms of Service