Un motore di ricerca WordPress per sviluppatori e autori di temi



rest_send_cors_headers ›

Da4.4.0
Deprecaton/a
rest_send_cors_headers ( $value )
Parametri:
  • (mixed) $value Response data.
    Richiesto:
Ritorna:
  • (mixed) Response data.
Definito a:
Codex:

Sends Cross-Origin Resource Sharing headers with API requests.



Sorgenti

function rest_send_cors_headers( $value ) {
	$origin = get_http_origin();

	if ( $origin ) {
		// Requests from file:// and data: URLs send "Origin: null"
		if ( 'null' !== $origin ) {
			$origin = esc_url_raw( $origin );
		}
		header( 'Access-Control-Allow-Origin: ' . $origin );
		header( 'Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE' );
		header( 'Access-Control-Allow-Credentials: true' );
		header( 'Vary: Origin' );
	}

	return $value;
}