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

Access-Control-Allow-Methods contains duplicate HTTP methods [SPR-14792] #19358

Closed
spring-projects-issues opened this issue Oct 10, 2016 · 0 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Oct 10, 2016

Mark Paluch opened SPR-14792 and commented

HTTP Header Access-Control-Allow-Methods contains duplicate method names using CORS Preflight requests. This happens when global, and handler CORS configurations are combined. Seems this can happen also for other CORS headers, see CorsConfiguration.combine .

class Config extends WebMvcConfigurerAdapter {

	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**").allowedMethods("GET").allowedOrigins("http://far.far.away");
	}
}

@RestController
class MyRestController {

	@RequestMapping(value = "/resource", method = RequestMethod.GET)
	@CrossOrigin
	String resource() {
		return "OK";
	}
}

@Test
public void allowedMethodsShouldContainUniqueMethodNames() throws Exception {

	mockMvc
			.perform(options("/resource") //
					.header(HttpHeaders.ORIGIN, "http://far.far.away") //
					.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
			.andExpect(status().isOk()) //
			.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET"));
}

Affects: 4.3 GA

Referenced from: commits f5ecdda, 9bf8489

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

Successfully merging a pull request may close this issue.

None yet
2 participants