Skip to content

Commit d4545b5

Browse files
committed
Add handling for preflight OPTIONS request
1 parent ca76a9c commit d4545b5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

wp-includes/rest-api/auth/class-wp-rest-token.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,15 @@ public function require_token() {
380380
$require_token = false;
381381
}
382382

383+
// Don't require a token or Authorization header for preflight OPTIONS
384+
// requests.
385+
if ( 'OPTIONS' === $request_method ) {
386+
$require_token = false;
387+
}
388+
383389
/**
384390
* GET requests do not typically require authentication, but if the
385-
* Authorization header is provided, we will use it. WHat's happening
391+
* Authorization header is provided, we will use it. What's happening
386392
* here is that `WP_REST_Token::get_auth_header` returns the bearer
387393
* token or a `WP_Error`. So if we have an error then we can safely skip
388394
* the GET request.

0 commit comments

Comments
 (0)