Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAMEL-21461: platform-http - add CORS support #1299

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rinaldodev
Copy link

Enable CORS support when using platform-http.

I'm unsure if this caching here could be an issue. Do we allow changing CORS configurations after initialization?

  if (corsConfiguration == null) {
      Map<String, String> corsHeaders = restConfiguration.getCorsHeaders();
      corsConfiguration = createCorsConfiguration(corsHeaders != null ? corsHeaders : Collections.emptyMap());
  }
  return corsConfiguration;

@Croway opening as draft to confirm if this is an issue. The following syntax doesn't work when testing CORS because it seems to overrides the behavior of all HTTP methods including OPTIONS. I don't think it's an issue since it's not the documented way of using rest DSL. Please confirm if you agree so I can remove the syntax from the test.

from("platform-http:/cors")
        .transform().constant("cors");

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { CamelAutoConfiguration.class,
SpringBootPlatformHttpCorsCredentialsTest.class, SpringBootPlatformHttpCorsCredentialsTest.TestConfiguration.class,
PlatformHttpComponentAutoConfiguration.class, SpringBootPlatformHttpAutoConfiguration.class, })
public class SpringBootPlatformHttpCorsCredentialsTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a negative test please?
ala

            .when()
            .get("/rest")
            .then()
            .statusCode(4xx/5xx)
            ```

@Croway
Copy link
Contributor

Croway commented Dec 2, 2024

@rinaldodev The following syntax doesn't work when testing CORS because it seems to overrides the behavior of all HTTP methods including OPTIONS this sounds odd, what about using httpMethodRestrict? do you think this can help somehow?

@Croway Croway requested a review from davsclaus December 2, 2024 09:21
Copy link
Contributor

@davsclaus davsclaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small thing, java source files should have ASF license headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants