spring-cloud / spring-cloud/spring-cloud-gateway

Spring Cloud Gateway - CORS issue (preflight request and response is success but actual request's response is FORBIDDEN)

Open
#2,704 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

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:

  1. 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).
  2. 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:
Response_To_Preflight_Request_is_SUCCESS

Actual Request and Response
Response_To_Actual_Request_is_FAILED_FORBIDDEN

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the application.yml global CORS configuration and compare the successful preflight request with the forbidden actual GraphQL request. Reproduce the behavior using Spring Boot 2.7.2 through the Spring Cloud Gateway, then determine what distinguishes the GraphQL route from the other successful Spring Boot application routes. Done means the actual request succeeds or the cause of the 403 is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.