API'S or Images has been blocked by CORS policy in Drupal 8:
When use REST Api in angular , then through the error CORS policy, to avoid ir
Change config in sites/default/services.yml
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: ['*']
# Configure requests allowed from specific origins.
allowedOrigins: ['*']
# Sets the Access-Control-Expose-Headers header.
exposedHeaders: false
# Sets the Access-Control-Max-Age header.
maxAge: false
# Sets the Access-Control-Allow-Credentials header.
supportsCredentials: false
Function to load only class name to avoid the page hanged or breaked when load whole object
get_class just like
kint(get_class($variables['element']['#object']->get('field_media_image')->entity))
output::
string(36) "Drupal\file_entity\Entity\FileEntity"
Comments
Post a Comment