<s>
Cross-origin	B-General_Concept
resource	I-General_Concept
sharing	I-General_Concept
(	O
CORS	B-General_Concept
)	O
is	O
a	O
mechanism	O
that	O
allows	O
restricted	O
resources	O
on	O
a	O
web	O
page	O
to	O
be	O
requested	O
from	O
another	O
domain	O
outside	O
the	O
domain	O
from	O
which	O
the	O
first	O
resource	O
was	O
served	O
.	O
</s>
<s>
A	O
web	O
page	O
may	O
freely	O
embed	O
cross-origin	O
images	O
,	O
stylesheets	O
,	O
scripts	O
,	O
iframes	B-General_Concept
,	O
and	O
videos	O
.	O
</s>
<s>
Certain	O
"	O
cross-domain	O
"	O
requests	O
,	O
notably	O
Ajax	B-General_Concept
requests	O
,	O
are	O
forbidden	O
by	O
default	O
by	O
the	O
same-origin	B-Protocol
security	I-Protocol
policy	I-Protocol
.	O
</s>
<s>
CORS	B-General_Concept
defines	O
a	O
way	O
in	O
which	O
a	O
browser	O
and	O
server	O
can	O
interact	O
to	O
determine	O
whether	O
it	O
is	O
safe	O
to	O
allow	O
the	O
cross-origin	O
request	O
.	O
</s>
<s>
It	O
allows	O
for	O
more	O
freedom	O
and	O
functionality	O
than	O
purely	O
same-origin	B-Protocol
requests	O
,	O
but	O
is	O
more	O
secure	O
than	O
simply	O
allowing	O
all	O
cross-origin	O
requests	O
.	O
</s>
<s>
The	O
specification	O
for	O
CORS	B-General_Concept
is	O
included	O
as	O
part	O
of	O
the	O
WHATWG	B-Language
's	O
Fetch	O
Living	O
Standard	O
.	O
</s>
<s>
This	O
specification	O
describes	O
how	O
CORS	B-General_Concept
is	O
currently	O
implemented	O
in	O
browsers	O
.	O
</s>
<s>
For	O
Ajax	B-General_Concept
and	O
HTTP	O
request	O
methods	O
that	O
can	O
modify	O
data	O
(	O
usually	O
HTTP	O
methods	O
other	O
than	O
GET	O
,	O
or	O
for	O
POST	B-Protocol
usage	O
with	O
certain	O
MIME	B-Protocol
types	O
)	O
,	O
the	O
specification	O
mandates	O
that	O
browsers	O
"	O
preflight	O
"	O
the	O
request	O
,	O
soliciting	O
supported	O
methods	O
from	O
the	O
server	O
with	O
an	O
HTTP	O
OPTIONS	O
request	O
method	O
,	O
and	O
then	O
,	O
upon	O
"	O
approval	O
"	O
from	O
the	O
server	O
,	O
sending	O
the	O
actual	O
request	O
with	O
the	O
actual	O
HTTP	O
request	O
method	O
.	O
</s>
<s>
A	O
CORS-compatible	O
browser	O
will	O
attempt	O
to	O
make	O
a	O
cross-origin	O
request	O
to	O
service.example.com	O
as	O
follows	O
.	O
</s>
<s>
The	O
browser	O
sends	O
the	O
GET	O
request	O
with	O
an	O
extra	O
Origin	O
HTTP	B-Protocol
header	I-Protocol
to	O
service.example.com	O
containing	O
the	O
domain	O
that	O
served	O
the	O
parent	O
page	O
:	O
</s>
<s>
The	O
requested	O
data	O
along	O
with	O
an	O
Access-Control-Allow-Origin	B-General_Concept
(	O
ACAO	O
)	O
header	O
in	O
its	O
response	O
indicating	O
the	O
requests	O
from	O
the	O
origin	O
are	O
allowed	O
.	O
</s>
<s>
The	O
requested	O
data	O
along	O
with	O
an	O
Access-Control-Allow-Origin	B-General_Concept
(	O
ACAO	O
)	O
header	O
with	O
a	O
wildcard	O
indicating	O
that	O
the	O
requests	O
from	O
all	O
domains	O
are	O
allowed	O
:	O
</s>
<s>
A	O
wildcard	O
same-origin	B-Protocol
policy	I-Protocol
is	O
appropriate	O
when	O
a	O
page	O
or	O
API	O
response	O
is	O
considered	O
completely	O
public	O
content	O
and	O
it	O
is	O
intended	O
to	O
be	O
accessible	O
to	O
everyone	O
,	O
including	O
any	O
code	O
on	O
any	O
site	O
.	O
</s>
<s>
A	O
freely	O
available	O
web	O
font	O
on	O
a	O
public	O
hosting	O
service	O
like	O
Google	B-Application
Fonts	I-Application
is	O
an	O
example	O
.	O
</s>
<s>
A	O
wildcard	O
same-origin	B-Protocol
policy	I-Protocol
is	O
also	O
widely	O
and	O
appropriately	O
used	O
in	O
the	O
object-capability	O
model	O
,	O
where	O
pages	O
have	O
unguessable	O
URLs	O
and	O
are	O
meant	O
to	O
be	O
accessible	O
to	O
anyone	O
who	O
knows	O
the	O
secret	O
.	O
</s>
<s>
Note	O
that	O
in	O
the	O
CORS	B-General_Concept
architecture	O
,	O
the	O
Access-Control-Allow-Origin	B-General_Concept
header	O
is	O
being	O
set	O
by	O
the	O
external	O
web	O
service	O
(	O
service.example.com	O
)	O
,	O
not	O
the	O
original	O
web	O
application	O
server	O
(	O
www.example.com	O
)	O
.	O
</s>
<s>
Here	O
,	O
service.example.com	O
uses	O
CORS	B-General_Concept
to	O
permit	O
the	O
browser	O
to	O
authorize	O
www.example.com	O
to	O
make	O
requests	O
to	O
service.example.com	O
.	O
</s>
<s>
When	O
performing	O
certain	O
types	O
of	O
cross-domain	O
Ajax	B-General_Concept
requests	O
,	O
modern	O
browsers	O
that	O
support	O
CORS	B-General_Concept
will	O
initiate	O
an	O
extra	O
"	O
preflight	O
"	O
request	O
to	O
determine	O
whether	O
they	O
have	O
permission	O
to	O
perform	O
the	O
action	O
.	O
</s>
<s>
The	O
HTTP	B-Protocol
headers	I-Protocol
that	O
relate	O
to	O
CORS	B-General_Concept
are	O
:	O
</s>
<s>
CORS	B-General_Concept
is	O
supported	O
by	O
all	O
browsers	O
based	O
on	O
the	O
following	O
layout	O
engines	O
:	O
</s>
<s>
MSHTML/Trident	B-Application
6.0	O
(	O
Internet	O
Explorer	O
10	O
)	O
has	O
native	O
support	O
.	O
</s>
<s>
MSHTML/Trident	B-Application
4.0	O
&	O
5.0	O
(	O
Internet	O
Explorer	O
8	O
&	O
9	O
)	O
provide	O
partial	O
support	O
via	O
the	O
XDomainRequest	O
object	O
.	O
</s>
<s>
Presto-based	O
browsers	O
(	O
Opera	B-Application
)	O
implement	O
CORS	B-General_Concept
as	O
of	O
Opera	B-Application
12.00	O
and	O
Opera	B-Language
Mobile	I-Language
12	O
,	O
but	O
not	O
Opera	B-Protocol
Mini	I-Protocol
.	O
</s>
<s>
WebKit	B-Language
(	O
Initial	O
revision	O
uncertain	O
,	O
Safari	O
4	O
and	O
above	O
,	O
Google	B-Application
Chrome	I-Application
3	O
and	O
above	O
,	O
possibly	O
earlier	O
)	O
.	O
</s>
<s>
Microsoft	B-Application
Edge	I-Application
All	O
versions	O
.	O
</s>
<s>
Cross-origin	O
support	O
was	O
originally	O
proposed	O
by	O
Matt	O
Oshry	O
,	O
Brad	O
Porter	O
,	O
and	O
Michael	O
Bodell	O
of	O
Tellme	O
Networks	O
in	O
March	O
2004	O
for	O
inclusion	O
in	O
VoiceXML	B-Application
2.1	O
to	O
allow	O
safe	O
cross-origin	O
data	O
requests	O
by	O
VoiceXML	B-Application
browsers	O
.	O
</s>
<s>
The	O
mechanism	O
was	O
deemed	O
general	O
in	O
nature	O
and	O
not	O
specific	O
to	O
VoiceXML	B-Application
and	O
was	O
subsequently	O
separated	O
into	O
an	O
implementation	O
NOTE	O
.	O
</s>
<s>
In	O
March	O
2009	O
the	O
draft	O
was	O
renamed	O
to	O
"	O
Cross-Origin	B-General_Concept
Resource	I-General_Concept
Sharing	I-General_Concept
"	O
and	O
in	O
January	O
2014	O
it	O
was	O
accepted	O
as	O
a	O
W3C	O
Recommendation	O
.	O
</s>
<s>
CORS	B-General_Concept
can	O
be	O
used	O
as	O
a	O
modern	O
alternative	O
to	O
the	O
JSONP	B-General_Concept
pattern	O
.	O
</s>
<s>
The	O
benefits	O
of	O
CORS	B-General_Concept
are	O
:	O
</s>
<s>
While	O
JSONP	B-General_Concept
supports	O
only	O
the	O
GET	O
request	O
method	O
,	O
CORS	B-General_Concept
also	O
supports	O
other	O
types	O
of	O
HTTP	O
requests	O
.	O
</s>
<s>
CORS	B-General_Concept
enables	O
a	O
web	O
programmer	O
to	O
use	O
regular	O
XMLHttpRequest	B-Protocol
,	O
which	O
supports	O
better	O
error	O
handling	O
than	O
JSONP	B-General_Concept
.	O
</s>
<s>
While	O
JSONP	B-General_Concept
can	O
cause	O
cross-site	O
scripting	O
(	O
XSS	O
)	O
issues	O
when	O
the	O
external	O
site	O
is	O
compromised	O
,	O
CORS	B-General_Concept
allows	O
websites	O
to	O
manually	O
parse	O
responses	O
to	O
increase	O
security	O
.	O
</s>
<s>
The	O
main	O
advantage	O
of	O
JSONP	B-General_Concept
was	O
its	O
ability	O
to	O
work	O
on	O
legacy	O
browsers	O
which	O
predate	O
CORS	B-General_Concept
support	O
(	O
Opera	B-Protocol
Mini	I-Protocol
and	O
Internet	B-Application
Explorer	I-Application
9	I-Application
and	O
earlier	O
)	O
.	O
</s>
<s>
CORS	B-General_Concept
is	O
now	O
supported	O
by	O
most	O
modern	O
web	O
browsers	O
.	O
</s>
