Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#47402 closed defect (bug) (worksforme)

Problem with Access-Control-Allow-Origin, on IOS Ionic 4 app

Reported by: pienoz's profile pienoz Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: REST API Keywords:
Focuses: Cc:


[REQUEST_URI] => /wp-json/wp/v2/posts?per_page=20&_embed

[HTTP_ORIGIN] => ionic://localhost

In wp-includes/rest-api.php, function : rest_send_cors_headers()

$origin = 'ionic://localhost'

After esc_url_raw( $origin ),

$origin is null

Result : Access-Control-Allow-Origin:

instead : Access-Control-Allow-Origin: ionic://localhost

Error on IOS : origin is not allowed by access-control-allow-origin

Change History (2)

#1 @ocean90
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Hello @pienoz, welcome to WordPress Trac!

ionic is not part of the default list of supported protocols by wp_allowed_protocols(). But you can easily extend the list with the help of the kses_allowed_protocols filter:

add_filter( 'kses_allowed_protocols', function( $protocols ) {
    $protocols[] = 'ionic';
    return $protocols;
} );

With this snippet you can continue to use ionic in the Origin header.

#2 @pienoz
5 years ago


With add_filter it's work !

Note: See TracTickets for help on using tickets.