Skip to content

Commit 04a0dfc

Browse files
committed
fix: pass down apikey as query param to realtime
1 parent 6e9af16 commit 04a0dfc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

internal/start/start.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type kongConfig struct {
8787
ApiHost string
8888
ApiPort uint16
8989
BearerToken string
90+
QueryToken string
9091
}
9192

9293
var (
@@ -362,6 +363,13 @@ EOF
362363
utils.Config.Auth.PublishableKey.Value,
363364
utils.Config.Auth.AnonKey.Value,
364365
),
366+
QueryToken: fmt.Sprintf(
367+
`$((function() return (query_params.apikey == '%s' and '%s') or (query_params.apikey == '%s' and '%s') or query_params.apikey end)())`,
368+
utils.Config.Auth.SecretKey.Value,
369+
utils.Config.Auth.ServiceRoleKey.Value,
370+
utils.Config.Auth.PublishableKey.Value,
371+
utils.Config.Auth.AnonKey.Value,
372+
),
365373
}); err != nil {
366374
return errors.Errorf("failed to exec template: %w", err)
367375
}

internal/start/templates/kong.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ services:
132132
- name: request-transformer
133133
config:
134134
replace:
135-
headers:
136-
- "Authorization: {{ .BearerToken }}"
137-
- name: realtime-v1-longpoll
135+
querystring:
136+
- "apikey:{{ .QueryToken }}"
137+
- name: realtime-v1-longpoll-not-working
138138
_comment: "Realtime: /realtime/v1/* -> ws://realtime:4000/socket/longpoll"
139139
url: http://{{ .RealtimeId }}:4000/socket
140140
protocol: http

0 commit comments

Comments
 (0)