Skip to content

Commit 05d6b7f

Browse files
committed
use different response status for non GET/HEAD
1 parent ddd48a4 commit 05d6b7f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

proxy/proxymanager.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,18 @@ func (pm *ProxyManager) proxyToUpstream(c *gin.Context) {
423423
// Check if this is exactly a model name with no additional path
424424
// and doesn't end with a trailing slash
425425
if remainingPath == "/" && !strings.HasSuffix(upstreamPath, "/") {
426-
// Redirect to add trailing slash
426+
// Build new URL with query parameters preserved
427427
newPath := "/upstream/" + searchModelName + "/"
428-
c.Redirect(http.StatusMovedPermanently, newPath)
428+
if c.Request.URL.RawQuery != "" {
429+
newPath += "?" + c.Request.URL.RawQuery
430+
}
431+
432+
// Use 308 for non-GET/HEAD requests to preserve method
433+
if c.Request.Method == http.MethodGet || c.Request.Method == http.MethodHead {
434+
c.Redirect(http.StatusMovedPermanently, newPath)
435+
} else {
436+
c.Redirect(http.StatusPermanentRedirect, newPath)
437+
}
429438
return
430439
}
431440
break

0 commit comments

Comments
 (0)