Skip to content

CORS #99

Answered by clue
juanbautista0 asked this question in Q&A
CORS #99
Dec 19, 2021 · 1 comment
Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SimonFrings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants