spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

fix: Ignore the Upgrade Websocket request

Open houkunlin opened this issue 2 years ago • 5 comments

spring:
  cloud:
    gateway:
      globalcors:
        cors-configurations:
          '[/**]':
            allowedOriginPatterns: "*"
            allowedHeaders: "*"
            allowedMethods: "*"
            allowCredentials: true
      routes:
        - id: test-stomp-info
          uri: lb://test
          predicates:
            - Path=/test/ws/stomp/info/**
        - id: rbac-stomp
          uri: lb:ws://test
          predicates:
            - Path=/test/ws/stomp/**
        - id: rbac
          uri: lb://test
          predicates:
            - Path=/**
      default-filters:
        - AddResponseHeader=Access-Control-Allow-Origin, *
        - AddResponseHeader=Access-Control-Allow-Methods, *
        - AddResponseHeader=Access-Control-Allow-Headers, *
        - AddResponseHeader=Access-Control-Allow-Credentials, true
        - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST

When forwarding the Websocket request in the above configuration, the forwarding may fail due to the modification of the Header. In this case, the DedupeResponseHeader needs to ignore the processing of the Upgrade request

houkunlin avatar Mar 22 '22 14:03 houkunlin

@houkunlin Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

pivotal-cla avatar Mar 22 '22 14:03 pivotal-cla

@houkunlin Thank you for signing the Contributor License Agreement!

pivotal-cla avatar Mar 22 '22 14:03 pivotal-cla

I don't understand, you're saying don't dedupe in certain cases? I think then, the dedupe filter shouldn't be a default one.

spencergibb avatar Mar 22 '22 15:03 spencergibb

Header information of cross-domain scenarios is processed at the gateway, and cross-domain headers are deduplicated. If they are not placed in the default filter, each of them needs to be set.

houkunlin avatar Mar 22 '22 15:03 houkunlin

Can you explain how to duplicate this? or add a test?

spencergibb avatar Mar 08 '24 22:03 spencergibb