bugfixes/cors-problem #7

Merged
TorstenHettstedt merged 9 commits from bugfixes/cors-problem into master 2021-04-13 12:44:22 +02:00
Owner

Der Server muss CORS und Preflight kennen.

Der Server muss CORS und Preflight kennen.
TorstenHettstedt added 6 commits 2021-04-12 19:51:09 +02:00
@@ -0,0 +23,4 @@
public function process(Request $request, RequestHandler $handler): Response
{
$response = $handler->handle($request);
Author
Owner

zu viele Zeilen.

zu viele Zeilen.
TorstenHettstedt marked this conversation as resolved
@@ -0,0 +39,4 @@
if ($this->testRoute($request)) {
$response = $response->withHeader('Access-Control-Allow-Origin', $this->buildOrigin($request));
$response = $response->withHeader('Access-Control-Allow-Methods', implode(',', $methods));
$response = $response->withHeader('Access-Control-Allow-Headers', $requestHeaders);
Author
Owner

Da fehlt noch was:
Access-Control-Max-Age: 86400

Da fehlt noch was: `Access-Control-Max-Age: 86400`
TorstenHettstedt marked this conversation as resolved
@@ -0,0 +42,4 @@
$response = $response->withHeader('Access-Control-Allow-Headers', $requestHeaders);
// Optional: Allow Ajax CORS requests with Authorization header
$response = $response->withHeader('Access-Control-Allow-Credentials', 'true');
Author
Owner

Braucht es das wirklich?

Braucht es das wirklich?
TorstenHettstedt marked this conversation as resolved
@@ -11,0 +13,4 @@
$I->haveHttpHeader('Origin', Api::TEST_ORIGIN);
$I->haveHttpHeader('Access-Control-Request-Method', 'GET');
$I->sendOptions('/views/working-hours/monthly');
$I->seeResponseCodeIs(HttpCode::OK);
Author
Owner

Es sollte auf die notwendigen Header geachtet werden:

Access-Control-Allow-Origin: http://foo.example
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: X-PINGOTHER, Content-Type
Access-Control-Max-Age: 86400
Es sollte auf die notwendigen Header geachtet werden: ``` Access-Control-Allow-Origin: http://foo.example Access-Control-Allow-Methods: POST, GET, OPTIONS Access-Control-Allow-Headers: X-PINGOTHER, Content-Type Access-Control-Max-Age: 86400
TorstenHettstedt marked this conversation as resolved
TorstenHettstedt added 2 commits 2021-04-13 12:43:09 +02:00
TorstenHettstedt added 1 commit 2021-04-13 12:43:35 +02:00
TorstenHettstedt merged commit 343f12b605 into master 2021-04-13 12:44:22 +02:00
TorstenHettstedt deleted branch bugfixes/cors-problem 2021-04-13 12:44:28 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TorstenHettstedt/PHP-App-Timekeeping#7