I am currently using CORS requests to communicate between my client and server located on different domains.
I have configured my Apache HTTP server to use SSL in the following manner:
// Utilizing AJAX withCredentials=true (sending cookies, allowing SSL...)
SetEnvIfNoCase ORIGIN (.*) ORIGIN=$1
Header always set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, PATCH, DELETE"
Header always set Access-Control-Allow-Origin "%{ORIGIN}e"
Header always set Access-Control-Allow-Credentials "true"
Header always set Access-Control-Allow-Headers "X-Accept-Charset,X-Accept,Content-Type"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]
My AJAX request looks like this:
$.ajax({ url: URL,
type: 'PUT',
xhrFields: {
withCredentials: true
},
crossDomain: true,
data: userPreferences,
success: function() { }
});
$.ajax({ url: URL,
type: 'GET',
xhrFields: {
withCredentials: true
},
crossDomain: true,
success: function() { }
});
The issue I am facing is that my GET request is successful, but the PUT request fails. In Google Chrome console, I receive the error message:
XMLHttpRequest cannot load https://URL. Method PUT is not allowed by Access-Control-Allow-Methods.
How can I resolve this problem?