Skip to content

Commit

Permalink
added cors middlewares to allow the webclient without hacky proxys
Browse files Browse the repository at this point in the history
Resolves #252
  • Loading branch information
CommanderStorm committed Oct 12, 2023
1 parent a78453f commit 24e369c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions deployment/charts/backend/files/envoy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ static_resources:
cors:
allow_origin_string_match:
- prefix: "*"
allow_methods: GET, PUT, DELETE, POST, OPTIONS
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
max_age: "1728000"
allow_methods: GET, DELETE, POST
allow_headers: "*"
max_age: "86400"
expose_headers: custom-header-1,grpc-status,grpc-message
http_filters:
- name: envoy.grpc_web
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: cors
labels:
app.kubernetes.io/part-of: tum-campus-app
namespace: {{ $.Values.namespace }}
spec:
headers:
accessControlAllowMethods:
- GET
- DELETE
- POST
accessControlAllowHeaders:
- "*"
accessControlAllowOriginList:
- "https://api.tum.app"
- "https://web.tum.app"
accessControlMaxAge: 86400
addVaryHeader: true
6 changes: 6 additions & 0 deletions deployment/charts/backend/templates/networking/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ spec:
port: 80
- kind: Rule
match: Host(`{{ join "`) || Host(`" $.Values.urls.v2 }}`)
middlewares:
- name: cors
services:
- name: backend-v2-svc
port: 50051
- kind: Rule
match: Host(`{{ join "`) || Host(`" $.Values.urls.v2WebGrpc }}`)
middlewares:
- name: cors
services:
- name: backend-v2-svc
port: 8081
- kind: Rule
match: (Host(`{{ join "`) || Host(`" $.Values.urls.v2 }}`)) && Headers(`Content-Type`, `application/grpc`)
middlewares:
- name: cors
services:
- name: backend-v2-svc
port: 50051
Expand Down

0 comments on commit 24e369c

Please sign in to comment.