Im working with Drupal 8 and Angular.
I want to create a content from angular.
I have the Get method working.
The problem is with the Post method, I don't know how to configure it.
With the Rest Ui module, i have this configuration:
And in the services.yml file I have this one:
cors.config:
enabled: true
# Specify allowed headers, like 'x-allowed-header'.
allowedHeaders: []
# 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
It works fine for the Get method, but for the POST, it gives me this error:
XMLHttpRequest cannot load http://drupal.dd:8083/entity/node. Preflight response is not successful task.service.ts:92
The task.service.ts is from my Angular app.
Questions:
1) Is the problem from Drupal configuration or from angular? (if is from angular, i will move the post. )
2)Wich on is the correct way to configure Post Method in Drupal?
allowedMethods: []
means no methods are allowed. So theOPTIONS
call fails. Add the appropriate methods to that array, clear the cache, it should work