Re: Access to XMLHttpRequest has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Francis Daly francis at daoine.org
Thu May 28 23:23:51 UTC 2020


On Thu, May 28, 2020 at 08:16:43PM +0530, Kaushal Shriyan wrote:
> On Thu, May 28, 2020 at 6:11 PM Francis Daly <francis at daoine.org> wrote:
> > On Thu, May 28, 2020 at 12:50:34PM +0530, Kaushal Shriyan wrote:

Hi there,

> > In your "drupal" nginx config, if the request is handled in the "php"
> > location, there is no Access-Control-Allow-Origin header added.
> >
> > You might want the "add_header" line there instead.

> I have added *add_header 'Access-Control-Allow-Origin' 'origin-list';* in
> the drupal Nginx config (/etc/nginx/conf.d/drupalbackend.conf)

> [root at nginx]# nginx -t -c /etc/nginx/nginx.conf
> > nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
> > nginx: configuration file /etc/nginx/nginx.conf test is successful

Presumably that file does "include" the file you modified?

> I am still encountering the same issue.
> 
> Access to XMLHttpRequest at '
> > https://tmobilereactdrupal.mydomain.com:8080/oauth/token' from origin '
> > https://tmobilereactdrupal.mydomain.com' has been blocked by CORS policy:
> > No 'Access-Control-Allow-Origin' header is present on the requested
> > resource.
> > POST https://tmobilereactdrupal.mydomain.com:8080/oauth/token
> > net::ERR_FAILED

What headers are present in the response to that POST request?

Does the drupal-nginx log file show that the request was received
by nginx?

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list