Drupal 8 has RESTful web service in-built in core and since 8.2 we don't need cors module.
Now to use services we just enable and configure default.service.yml file as specified in here
However, I was not able to configure this setup to allow web service access over another domain.
My current service.yml setup for cors is:
cors.config: enabled: true # Specify allowed headers, like 'x-allowed-header'. allowedHeaders: ['x-csrf-token,authorization,content-type,accept,origin,x-requested-with'] # Specify allowed request methods, specify ['*'] to allow all possible ones. allowedMethods: ['POST, GET, OPTIONS, DELETE, PUT'] # Configure requests allowed from specific origins. allowedOrigins: ['*'] # Sets the Access-Control-Expose-Headers header. exposedHeaders: false # Sets the Access-Control-Max-Age header. maxAge: 1000 # Sets the Access-Control-Allow-Credentials header. supportsCredentials: false
I googled to find further detailed configuration on this but could not find one.
I am creating this for test development across two different domains.
Using pantheon dev environment for web services and localhost custom .dev domain for consuming those services.
Service access working fine using chrome CORS extension.