- Feature: CORS configuration can now be passed to the
RestApiconstructor which will activate for your endpoints.
new RestApi([
'namespace' => 'EvoMark\\OurProject\\RestApi\\',
'version' => 1,
'directory' => $environment->rootPath . 'src/RestApi',
'base_url' => 'evomark',
'cors' => [
'allow_origin' => '*',
'allow_headers' => ['X-My-Custom-Header'],
'expose_headers' => ['Something'],
'allow_methods' => ['GET', 'OPTIONS'],
'allow_credentials' => false
]
]);The following filters are also available: evo_wp_rest_allow_origin, evo_wp_rest_allow_methods and evo_wp_rest_allow_credentials. All receive the response, request and server as additional arguments.