I am using the RESTful Web Services that is included in core of Drupal 8.2.7. I need to activate CORS to be able to call the API from another domain.

I put this configuration in this file: "core/lib/Drupal/Core/core.services.yml" but it didn't work. I don't have the header Access-Control-Allow-Origin.

  enabled: true
  allowedHeaders: ['*']
  allowedMethods: ['*']
  allowedOrigins: ['*']
  exposedHeaders: true
  maxAge: true
  supportsCredentials: true

I found also this configuration is present in "sites/default/default.services.yml".

What is the proper way to configure CORS ?

1 Answer 1


To override container variables you have to enable this line in sites/default/settings.php (is enabled by default)

$settings['container_yamls'][] = __DIR__ . '/services.yml';

and then copy sites/default/default.services.yml to sites/default/services.yml.

Now you can configure the variables in services.yml.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.