CORS Header Configuration

Last Updated: May 2, 2021
documentation for the dotCMS Content Management System

You can specify CORS headers to include in REST responses. These headers can be set as global defaults and can be overridden on an endpoint by endpoint basis. The endpoint-specific headers completely override the default headers; each REST resource will send the resource-specific headers (and ignore the default headers) if they have been specified, but will fall back to the default CORS headers if no resource-specific headers are configured.

Setting Global CORS Headers

To set a global default CORS header, you must add a new property to the file in the following form:


For example, if you want to set the default header Access-Control-Allow-Origin : *, add the following property to the file:


Default CORS Headers

The following CORS headers are set by default in the file:

api.cors.default.access-control-allow-headers=Authorization, Accept, Cookies, Content-Type, Content-Length
api.cors.default.access-control-allow-methods=GET, HEAD, POST, PUT, DELETE, OPTIONS

Overriding Headers for Specific Resources

You can also override CORS headers per resource by replacing .default. in the property name Java class name of the resource (in lower case).

For example, the/api/content REST calls are implemented in the ContentResource.class. Adding the following properties to the file will set specific CORS headers for this resource:

api.cors.contentresource.access-control-allow-headers=Authorization, Accept, Cookies, Content-Type, Content-Length
api.cors.contentresource.access-control-allow-methods=GET, HEAD, POST, PUT, DELETE, OPTIONS

On this page


We Dig Feedback

Selected excerpt: