Skip to content

Instantly share code, notes, and snippets.

@rpayanm
Last active November 11, 2021 13:51
Show Gist options
  • Save rpayanm/edbcf41e3d641dbba718cacc028177b5 to your computer and use it in GitHub Desktop.
Save rpayanm/edbcf41e3d641dbba718cacc028177b5 to your computer and use it in GitHub Desktop.
Allow other domain do Rest request to drupal site:
- Use `services.yml`:
```
cors.config:
enabled: true
# Specify allowed headers, like 'x-allowed-header'.
allowedHeaders: ['*'] # All header
# Specify allowed request methods, specify ['*'] to allow all possible ones.
allowedMethods: ['GET'] # Methods
# Configure requests allowed from specific origins.
allowedOrigins: ['http://livgmayo.local', 'https://dev.livgenerationsahwatukee.com'] # Allow origins You MUST NOT include '/' at the end.
# Sets the Access-Control-Expose-Headers header.
exposedHeaders: false # Same
# Sets the Access-Control-Max-Age header.
maxAge: false # Same
# Sets the Access-Control-Allow-Credentials header.
supportsCredentials: false # Same
```
- Include it in settings.php:
`$settings['container_yamls'][] = $app_root . '/sites/services.yml';`
- Clear cache every time you edit this file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment