CORS Extension

This extension configures specified CORS headers for the endpoints exposed by the REST API (Restful Objects Viewer).

To learn more about CORS, see for example this blog post at www.moesif.com

Setup

Dependency Management

In your application’s top level pom.xml, add a dependency for this module’s own bill of materials (BOM):

pom.xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.causeway.extensions</groupId>
            <artifactId>causeway-extensions-cors</artifactId>
            <scope>import</scope>
            <type>pom</type>
            <version>2.0.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Dependencies / Imports

In the webapp module of your application, add the following dependency:

pom.xml
<dependency>
    <groupId>org.apache.causeway.extensions</groupId>
    <artifactId>causeway-extensions-cors-impl</artifactId>
</dependency>

In your application’s App Manifest, import the extension’s implementation module:

AppManifest.java
@Configuration
@Import({
        CausewayModuleExtCors.class,
        ...
})
public class AppManifest {
}

Configuration

Update the configuration properties:

application.yml
causeway:
    extensions:
        cors:
            allow-credentials: ...  (1)
            allow-headers: ...      (2)
            allow-methods: ...      (3)
            allow-origins: ...      (4)
            exposed-headers: ...    (5)