Spring Cloud Gateway - CORS issue (preflight request and response is success but actual request's response is FORBIDDEN)
Hello Together,
Below is my Global CORS configuration (i.e. in application.yml file) in the Spring Cloud API Gateway application and my preflight response is success. But then the actual graphql micro service request is failed with 403 FORBIDDEN error.
Please help to solve the issue.
Note:
- I didn't configure spring security (i.e. didn't add spring-boot-starter-security dependency) in both Spring cloud gateway application and graphql spring boot application (i.e. Micro service).
- Except graphql micro service other normal spring boot application request and response is success via Spring Cloud API Gateway.
Spring Boot Version : 2.7.2
global cors configuration
globalcors:
add-to-simple-url-handler-mapping: true
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedHeaders: "*"
allowedMethods: "*"
Prelflight Request and Response:

Actual Request and Response

Maybe U should add this dependency to U pom.xml:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
And some metadata in spring-autoconfigure-metadata.properties looks like :
org.springframework.cloud.util.ConditionalOnBootstrapDisabled$OnBootstrapDisabledCondition$OnBootstrapMarkerClassPresent=
org.springframework.cloud.util.ConditionalOnBootstrapDisabled$OnBootstrapDisabledCondition$OnBootstrapMarkerClassPresent.ConditionalOnClass=org.springframework.cloud.bootstrap.marker.Marker
org.springframework.cloud.util.ConditionalOnBootstrapEnabled$OnBootstrapEnabledCondition$OnBootstrapMarkerClassPresent=
org.springframework.cloud.util.ConditionalOnBootstrapEnabled$OnBootstrapEnabledCondition$OnBootstrapMarkerClassPresent.ConditionalOnClass=org.springframework.cloud.bootstrap.marker.Marker
in U classpath, then U yml configuration file will work
@lgscofield : Hello Bro, Any other solution as I don't want to make changes in the Spring Boot components .