From 246aa65a1992e6041f8b9e0df4f34c0738d26bfd Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Mon, 17 Oct 2016 16:10:37 +0000 Subject: [PATCH] REST API: Include `Vary: Origin` in cors headers `vary: origin` is a W3 CORS implementation recommendation( https://www.w3.org/TR/cors/#resource-implementation ). It's used by default in frameworks such as hapi and Laravel-cors. Overall, it helps sites siting behind a cache such as varnish. Fixes #38060. Props procodewp, pdufour for research. git-svn-id: https://develop.svn.wordpress.org/trunk@38806 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index 620ca925b9..6da931e77a 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -408,6 +408,7 @@ function rest_send_cors_headers( $value ) { header( 'Access-Control-Allow-Origin: ' . esc_url_raw( $origin ) ); header( 'Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE' ); header( 'Access-Control-Allow-Credentials: true' ); + header( 'Vary: Origin' ); } return $value;