Access-Control-Allow-Methods 不允许 Cors 请求方法 PUT
Cors request method PUT is not allowed by Access-Control-Allow-Methods
我正在使用 Cors 请求在位于两个不同域中的客户端和服务器之间进行通信。
我使用 SSL 以这种方式配置我的 apache http 服务器:
//with AJAX withCredentials=true (cookies sent, SSL allowed...)
SetEnvIfNoCase ORIGIN (.*) ORIGIN=
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 ^(.*)$ [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]
我的ajax请求是这样的:
$.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() { }
});
此配置的结果是,我的 get 请求有效但我的 put 请求无效,我在 google chrome 控制台中收到以下错误(我用 firefox 尝试过)
XMLHttpRequest cannot load https://URL. Method PUT is not allowed by Access-Control-Allow-Methods.
我该如何解决这个问题?
我在我的 Apache 配置中输错了这一行
Header always set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, PATCH, DELETE"
我输入了没有 S 的方法,这就是我收到此错误的原因:
XMLHttpRequest cannot load https://URL. Method PUT is not allowed by Access-Control-Allow-Methods.
无论如何,我上面写的所有配置都是 tested/working 启用 cors 和 SSL 的解决方案。
我正在使用 Cors 请求在位于两个不同域中的客户端和服务器之间进行通信。
我使用 SSL 以这种方式配置我的 apache http 服务器:
//with AJAX withCredentials=true (cookies sent, SSL allowed...)
SetEnvIfNoCase ORIGIN (.*) ORIGIN=
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 ^(.*)$ [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]
我的ajax请求是这样的:
$.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() { }
});
此配置的结果是,我的 get 请求有效但我的 put 请求无效,我在 google chrome 控制台中收到以下错误(我用 firefox 尝试过)
XMLHttpRequest cannot load https://URL. Method PUT is not allowed by Access-Control-Allow-Methods.
我该如何解决这个问题?
我在我的 Apache 配置中输错了这一行
Header always set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, PATCH, DELETE"
我输入了没有 S 的方法,这就是我收到此错误的原因:
XMLHttpRequest cannot load https://URL. Method PUT is not allowed by Access-Control-Allow-Methods.
无论如何,我上面写的所有配置都是 tested/working 启用 cors 和 SSL 的解决方案。