Handling CORS Errors with Drupal's JSON:API
Overview When using the output from Drupal’s JSON:API in a separate application, a CORS error occurred. Here, I explain how to resolve the CORS error. Solution Copy the following file: /web/sites/default/default.services.yml cp /web/sites/default/default.services.yml /web/sites/default/services.yml Then, set enabled to true in cors.config: # Configure Cross-Site HTTP requests (CORS). # Read https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS # for more information about the topic in general. # Note: By default the configuration is disabled. cors.config: enabled: false # Change this to true! # Specify allowed headers, like 'x-allowed-header'. allowedHeaders: [] As a result, the CORS error was resolved. ...














