VMware Cloud Community
bits10
Contributor
Contributor

How to configure CORS in Spring cloud gateway for VMware Tanzu?

Hi All,

We want to configure CORS for one of the spring-boot bound app to gateway. we did following attempt but none of them worked.

  • Added CORS configuration at srping-boot app level, but it only work from app container not from gateway.
  • We updated our gateway successfully by running cf update-service gateway -c '{ "cors": { "allowed-origins": [ "*"], "allowed-methods":[ "GET", "OPTIONS"] }}'  but did not worked.
  • We also disabled the secure header in-case causing the issue by running cf update-service gateway -c '{ "disable-secure-headers": false }'.

Could anyone please help us on this ?

Labels (3)
3 Replies
jgbutler
VMware Employee
VMware Employee

Perhaps you should use "allowed-origin-patterns: ["*"]" rather than "allowed-origins: ["*"]"

 

walter545
Contributor
Contributor

I have exactly the same issue. Anyone got a thought?

 

epayitonline

0 Kudos
bits10
Contributor
Contributor

Hi @jgbutler 

It did not work. do we need to change some configuration before running this ?

cf update-service gateway -c '{ "cors": { "allowed-origin-patterns": ["*"], "allowed-methods":[ "GET", "OPTIONS"] }}'
Updating service instance gateway as -------...
FAILED
Server error, status code: 502, error code: 10001, message: Service broker error: Service broker parameters are invalid: #/cors: extraneous key [allowed-origin-patterns] is not permitted