Skip to content

Commit f83cb83

Browse files
committed
fix: query key
1 parent 148e8be commit f83cb83

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/proxy/server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,13 @@ func (ps *ProxyServer) executeRequestWithRetry(c *gin.Context, startTime time.Ti
262262
if c.GetHeader("Authorization") != "" {
263263
req.Header.Set("Authorization", "Bearer "+keyInfo.Key)
264264
req.Header.Del("X-Goog-Api-Key")
265-
} else if c.GetHeader("X-Goog-Api-Key") != "" || c.Query("key") != "" {
265+
} else if c.GetHeader("X-Goog-Api-Key") != "" {
266266
req.Header.Set("X-Goog-Api-Key", keyInfo.Key)
267267
req.Header.Del("Authorization")
268+
} else if c.Query("key") != "" {
269+
q := req.URL.Query()
270+
q.Set("key", keyInfo.Key)
271+
req.URL.RawQuery = q.Encode()
268272
} else {
269273
c.JSON(http.StatusUnauthorized, gin.H{
270274
"error": "API key required. Please provide a key in 'Authorization' or 'X-Goog-Api-Key' header.",

0 commit comments

Comments
 (0)