Skip to content

Commit 86cf055

Browse files
authored
Remove settings of CORS heads in the options block. (#1681)
1 parent 20e6a67 commit 86cf055

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

cwms-data-api/src/main/java/cwms/cda/ApiServlet.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ public void init() {
410410
})
411411
.routes(this::configureRoutes)
412412
.options("/*", ctx -> {
413-
ctx.header("Access-Control-Allow-Origin", "*"); // Allow requests from any origin
414-
ctx.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); // Specify allowed methods
415-
ctx.header("Access-Control-Allow-Headers", "Content-Type, Authorization"); // Specify allowed headers
416-
ctx.status(200); // Respond with a 200 OK status
413+
// Respond with a 200 OK status for preflight checks.
414+
// It is expected that the firewall in front of the API
415+
// will handle any CORS headers.
416+
ctx.status(200);
417417
})
418418
.javalinServlet();
419419
QueueManager.ensureRssSubscribers(cwms);

cwms-data-api/src/test/java/cwms/cda/api/BaseLineTestIT.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ void test_options_handling_known_url(String url) throws Exception {
3434
.then()
3535
.log().ifValidationFails(LogDetail.ALL,true)
3636
.assertThat()
37-
.statusCode(is(HttpServletResponse.SC_OK))
38-
.header("Access-Control-Allow-Methods", equalTo("GET, POST, PUT, DELETE, OPTIONS"))
39-
.header("Access-Control-Allow-Headers", equalTo("Content-Type, Authorization"));
37+
.statusCode(is(HttpServletResponse.SC_OK));
4038
}
4139

4240
@ParameterizedTest
@@ -51,8 +49,6 @@ void test_options_handling_unknown_url(String url) throws Exception {
5149
.then()
5250
.log().ifValidationFails(LogDetail.ALL,true)
5351
.assertThat()
54-
.statusCode(is(HttpServletResponse.SC_OK))
55-
.header("Access-Control-Allow-Methods", nullValue())
56-
.header("Access-Control-Allow-Headers", nullValue());
52+
.statusCode(is(HttpServletResponse.SC_OK));
5753
}
5854
}

0 commit comments

Comments
 (0)