Recall & Review
beginner
What does CORS stand for and why is it important?
CORS stands for Cross-Origin Resource Sharing. It is important because it controls how web pages can request resources from a different domain, protecting users from malicious websites accessing data they shouldn't.
Click to reveal answer
intermediate
What is a 'preflight request' in CORS?
A preflight request is an automatic OPTIONS request sent by the browser before the actual request. It checks if the server allows the real request method and headers from the origin.
Click to reveal answer
beginner
How can you test CORS policies using Postman?
In Postman, you can simulate CORS requests by setting the 'Origin' header manually and sending requests to the server. You check the server's response headers like 'Access-Control-Allow-Origin' to verify CORS behavior.
Click to reveal answer
beginner
What response header indicates that a server allows cross-origin requests?
The 'Access-Control-Allow-Origin' header indicates which origins are allowed to access the resource. If it matches the request origin or is '*', the request is allowed.
Click to reveal answer
intermediate
Why might a CORS request fail even if the server responds?
A CORS request might fail if the server does not include the correct 'Access-Control-Allow-Origin' header or if the preflight OPTIONS request is rejected. Browsers block the response for security.
Click to reveal answer
Which header must a server send to allow cross-origin requests?
✗ Incorrect
The 'Access-Control-Allow-Origin' header tells the browser which origins are allowed to access the resource.
What HTTP method is used for a CORS preflight request?
✗ Incorrect
The browser sends an OPTIONS request before the actual request to check if the server allows it.
In Postman, how do you simulate a CORS request?
✗ Incorrect
Postman does not enforce CORS, so you simulate it by adding the 'Origin' header manually.
What does a wildcard '*' in 'Access-Control-Allow-Origin' mean?
✗ Incorrect
A '*' means the server allows requests from any origin.
Why do browsers block CORS requests without proper headers?
✗ Incorrect
Browsers block such requests to protect users from malicious websites accessing sensitive data.
Explain how you would test CORS behavior using Postman.
Think about how browsers check CORS and how Postman can mimic that.
You got /4 concepts.
Describe what happens during a CORS preflight request and why it is needed.
Consider the safety checks browsers do before sending certain requests.
You got /4 concepts.