CORS with XMLHttpRequest [英] CORS with XMLHttpRequest
问题描述
我想在两个网站之间发出POST请求。
I'm trying to make a POST request between two sites.
我已经看到需要更改服务器端的请求头使用access-allow 。我的问题是,当我发送请求我不能看到这个修改在响应头。
I've seen the need to change header of request on server side using the access-allow. My problem is that when I send request I can't see this modification in the response header.
如果我直接在页面上更改标题。如果我用GET发送请求,我也可以看到头已经改变。也许有服务器配置的http,是禁止跨域POST请求?
If I go on directly on page the headers are change. If I sent request with GET, I can see too that the headers has been changed. Maybe there is server configuration of http which is forbidden across domain POST request?
我使用一个Ngnix服务器为Drupal网站。
I'm using a Ngnix server that serves Drupal sites.
推荐答案
据我所知,您应该更改的标头是接收请求(或网站2)的网站的响应标头。因此,它允许客户端(或站点1)执行CORS请求,将头部访问控制允许原因和站点1(或*)的域添加到响应中。
As far as I know, the header you should change is the response header of the site that receive the request (or site 2). Thus, it allows the client (or site 1) to perform a CORS request, adding the header "Access-Control-Allow-Origin" and the domain of site 1 (or '*') into the response.
这篇关于CORS with XMLHttpRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!