CORS #99
Answered
by
clue
juanbautista0
asked this question in
Q&A
CORS
#99
-
in the constructor of the React\Http\Message\Response object can CORS be enabled? |
Beta Was this translation helpful? Give feedback.
Answered by
clue
Dec 20, 2021
Replies: 1 comment
-
Excellent question! CORS headers are supported just like any other response headers. $app->get('/user', function () {
return new React\Http\Message\Response(
200,
[
'Content-Type' => 'text/plain; charset=utf-8',
'Access-Control-Allow-Origin' => '*'
],
"Hello wörld"
);
}); See https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS and https://framework-x.org/docs/api/response/#headers. Depending on your use case, you may add these headers for each route or use a middleware implementation that can be reused for a number of routes. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SimonFrings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent question! CORS headers are supported just like any other response headers.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS and https://framework-x.org/docs/api/response/#headers.
Depending on your use case, you may add these headers for each route or use a middleware implementation that can be reused for a number of routes.