CORS Flashcards
What does CORS stand for?
Cross-Origin Resource Sharing
What is CORS?
CORS is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources.
You load a React app from www.domain1.com.
Then you make requests using JS and fetch to the same domain.
Do you need to consider CORS?
No as you are sending requests to the original domain you don’t need to worry about CORS.
You load a React app from www.domain1.com.
Then you make requests using JS and fetch to www.domain2.com
Do you need to consider CORS?
Yes, as you are sending requests to a different domain than where you retrieved the React app from www.domain2.com will need to send the correct CORS headers.
What defines the origin?
The main request made for a web page. For a React app it would be getting the index.html. (I assume)
A request is sent via JS with these headers, where is the request being sent to and from?
Host: oneedfhirtest.azurewebsites.net
Origin: http://localhost:3000
The request is being sent to the server oneedfhirtest.azurewebsites.net
from the application that was loaded from http://localhost:3000.