Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How do I go about adding CORS to a view which is formatted as a JSON data document?
I tried adding it to my .htaccess but I think since Drupal is generating the JSON, it doesn't have any effect. And I cannot find an option other than enabling JSONP to have other sites access these JSON views?
Comments
Comment #2
ZeiP CreditAttribution: ZeiP as a volunteer commentedCORS headers can be added using the CORS module: https://www.drupal.org/project/cors
I'll add this to the module README and module description, thanks for the relevant question!
Comment #4
ZeiP CreditAttribution: ZeiP as a volunteer commentedComment #6
noopal CreditAttribution: noopal commentedhi
I can't get cors to work.
I have added the Cors module
I have put the
url of view | *
I was expecting that any url can access the json view. But I still get
'has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.'
Do I need to change something?
Thanks
Comment #7
ZeiP CreditAttribution: ZeiP at Ardcoras oy commented@noopal, please open a new support request in the CORS module issue queue: https://www.drupal.org/project/issues/cors?categories=All