Api cordova ios

Hello, I have the following problem (https://issues.apache.org/jira/browse/CB-14124), in Apache they tell me that the problem is with the API.
In the API I have this and I still have the same problem, any solution?
https://prnt.sc/jwlie7

Perhaps an HTTP preflight request causes the problem:

I have added this (http://prntscr.com/jx81tk) and it remains the same :confused:

Could you please try to add this middleware in your middleware.php?

use Slim\Http\Request;
use Slim\Http\Response;

// CORS preflight middleware
$app->add(function (Request $request, Response $response, $next) {
    if ($request->getMethod() !== 'OPTIONS') {
        return $next($request, $response);
    }
    $response = $next($request, $response);
    $response = $response->withHeader('Access-Control-Allow-Origin', '*');
    $response = $response->withHeader('Access-Control-Allow-Methods', $request->getHeaderLine('Access-Control-Request-Method'));
    $response = $response->withHeader('Access-Control-Allow-Headers', $request->getHeaderLine('Access-Control-Request-Headers'));
    return $response;
});

Hello, this is incredible, today I tested and it works correctly with this (Screenshot by Lightshot)

Maybe it’s the cache.

I am curious and I have tried the middleware.php and it has given me this error:

Type: TypeError
Message: Argument 1 passed to Closure::{closure}() must be an instance of Request, instance of Slim\Http\Request given
File: api/src/middleware.php
Line: 8

Regards, and thank you very much!

That’s because the namespace definition is missing on top of the php file: middleware.php

<?php

use Slim\Http\Request;
use Slim\Http\Response;

//...

ok, now it works, thank you very much for everything!
a greeting!

1 Like