Skip to content

Enable/Disable Spring CORS option [SPR-13691] #18266

Closed
@spring-projects-issues

Description

@spring-projects-issues

SPT Developer opened SPR-13691 and commented

I am using my original CORS interceptor and dispatching OPTIONS request for pre-flight.

servlet.setDispatchOptionsRequest(true);

After upgraded Spring Boot to 1.3.0 RC1 with Spring 4.2.2, Spring CORS intercepted my original. In order to disable Spring CORS, I added CorsUtils in my classpath temporary.

package org.springframework.web.cors;

import javax.servlet.http.HttpServletRequest;

/**
 * CORS utility (Overriding)
 */
public class CorsUtils {
	
	/**
	 * Returns {@code true} if the request is a valid CORS one.
	 */
	public static boolean isCorsRequest(HttpServletRequest request) {
		// Disable Spring CORS by force.
		return false;
	}
	
	/**
	 * Returns {@code true} if the request is a valid CORS pre-flight one.
	 */
	public static boolean isPreFlightRequest(HttpServletRequest request) {
		// Disable Spring CORS by force.
		return false;
	}
}

To fix it permanently, please add option to swith on/off Spring CORS.

if (!enableSpringCors || !CorsUtils.isCorsRequest(request)) {
	......
if (enableSpringCors && CorsUtils.isCorsRequest(request)) {
	......
if (this.dispatchOptionsRequest || (enableSpringCors && CorsUtils.isPreFlightRequest(request))) {
	......
if (enableSpringCors && CorsUtils.isPreFlightRequest(request)) {
	......

Affects: 4.2.2

Issue Links:

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions