Trying to set up an app with headless Drupal 8 and blocked with the below error ?
No 'Access-Control-Allow-Origin' header is present on the requested resource
This is happening since you are missing some configuration related to Cross Origin Resource Sharing (CORS)
Mar 14, 2015 Headless Drupal 8 Out of the box Drupal 8 has a RESTful API. So you are covered for a great part when you install the Drupal 8 core. In addition, the developers of the Restful module will build extra tools that the Drupal core does not offer, like the OPTIONS call. I am successfully using a headless Drupal 8 setup that I am querying through Drupal 8 core REST API with basic auth from jQuery AJAX. Now I need to get closer to production conditions, so I started trying to use cookie-based authentication. Problem is that the exact same query that successfully POSTed content using basic auth now returns an. Headless Drupal 8 is quickly becoming a priority architecture for enterprises seeking to better engage customers across a growing number of channels devices. Headless Drupal architecture decouples Drupal’s back-end capabilities for managing content from the front-end tools for rendering and displaying content on websites, mobile devices and other digital experiences. A headless Drupal solution offered a powerful and flexible solution that allowed for sites to be spun up quickly, something Drupal 8 is capable of alone. But in this case, a headless allowed more customization for the client. Boreal Mountain Resort is part of a large system of 18 ski areas.
Latest D8 version is capable enough to adjust this issue.
For that locate your default.services.yml file
Headless Drupal 8 Page
Headless Drupal 8 Download
It should be there in <'Your_Project_Directory'>/sites/default/default.services.yml
Copy this file and paste it in the same directory. Rename it to services.yml
Headless Drupal 8 Free
Locate the cors.config section in file.
Headless Drupal 8 6
Headless Drupal 8
And change the configuration as shown below.