Add Access-Control-Allow-Origin to API Gateway based on Nginx #597
Closed
giulioroggero
started this conversation in
Show and tell
Replies: 3 comments 1 reply
|
Do you know how to do the same with envoy api-gateway? |
1 reply
|
In my case i needed also all subpaths to be available from other origins. To achieve this with Envoy API Gateway, i defined the whole endpoint in advanced mode, without creating an endpoint from the console Endpoint section. This allowed me to cover all subpaths without overwriting one by one the specific routes which are automatically configured by the console. http-filters.yaml - listener_name: frontend
name: envoy.filters.http.cors
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.cors.v3.Corsclusters.yaml - "@type": type.googleapis.com/envoy.config.cluster.v3.Cluster
name: crud-service-cluster
connect_timeout: 0.5s
type: LOGICAL_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: crud-service-cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: crud-service
port_value: 80endpoints.yaml - listener_name: frontend
match:
prefix: "/v2/claims"
route:
cluster: "crud-service-cluster"
prefix_rewrite: "/claims"
typed_per_filter_config:
"envoy.filters.http.cors":
"@type": "type.googleapis.com/envoy.extensions.filters.http.cors.v3.CorsPolicy"
allow_origin_string_match:
- prefix: "*"
"allow_methods": "GET, POST, PUT, PATCH, DELETE, OPTIONS"
"allow_headers": "*"
"max_age": "86400"
"allow_credentials": true |
0 replies
|
An updated config for new envoy versions. Please note: remove the endpoints configured in advanced from Console->Design->Endpoint otherwise envoy has two configuration for the same endpoint and the behaviour is random! endpoints.yaml |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
To setup it you can use the Advanced section in Console/Project/Design and configuring the following files
server-extension.conf
upstreams.conf
change crud-service with your microservice
All reactions