Skip to content

Commit 5c10e90

Browse files
authored
Merge pull request #153 from WP-API/cors-support
Add CORS support
2 parents 990591b + 7c1cc0b commit 5c10e90

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

oauth-server.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ function rest_oauth1_loaded() {
108108
if ( empty( $GLOBALS['wp']->query_vars['rest_oauth1'] ) )
109109
return;
110110

111+
rest_send_cors_headers( null );
112+
header( 'Access-Control-Allow-Headers: Authorization' );
113+
114+
if ( $_SERVER['REQUEST_METHOD'] === 'OPTIONS' ) {
115+
die();
116+
}
117+
111118
$authenticator = new WP_REST_OAuth1();
112119
$response = $authenticator->dispatch( $GLOBALS['wp']->query_vars['rest_oauth1'] );
113120

0 commit comments

Comments
 (0)