diff --git a/src/main/java/org/eclipsefoundation/adopters/response/CORSFilter.java b/src/main/java/org/eclipsefoundation/adopters/response/CORSFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..b691ef395f148821e1b78a9a2eb96f7e9f8b35ec --- /dev/null +++ b/src/main/java/org/eclipsefoundation/adopters/response/CORSFilter.java @@ -0,0 +1,34 @@ +/** + * ***************************************************************************** Copyright (C) 2020 + * Eclipse Foundation + * + * <p>This program and the accompanying materials are made available under the terms of the Eclipse + * Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * <p>SPDX-License-Identifier: EPL-2.0 + * **************************************************************************** + */ +package org.eclipsefoundation.adopters.response; + +import java.io.IOException; +import java.util.Arrays; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.ext.Provider; + +import org.eclipse.microprofile.config.inject.ConfigProperty; + +@Provider +public class CORSFilter implements ContainerResponseFilter { + @ConfigProperty(name = "quarkus.http.cors.exposed-headers") + String exposedHeaders; + + @Override + public void filter( + ContainerRequestContext requestContext, ContainerResponseContext responseContext) + throws IOException { + responseContext.getHeaders().put("Access-Control-Expose-Headers", Arrays.asList(exposedHeaders)); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a2513892fe0fb8cc93c4ceb774fe4519614ab6cd..7626e027382f9703f64fd6a11b170808f4a8c2af 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,6 +4,10 @@ org.eclipsefoundation.adopters.api.ProjectsAPI/mp-rest/url=https://projects.ecli quarkus.http.port=8080 quarkus.http.root-path=/adopters +## CORS settings +quarkus.http.cors=true +quarkus.http.cors.exposed-headers=Etag,Link,Content-Type + ## Adopters raw location eclipse.adopters.path.json=/config/adopters.json %dev.eclipse.adopters.path.json=/tmp/config/adopters.json \ No newline at end of file