diff --git a/plugins/wasm-go/extensions/ai-proxy/main.go b/plugins/wasm-go/extensions/ai-proxy/main.go index f4d67de42..3c5676129 100644 --- a/plugins/wasm-go/extensions/ai-proxy/main.go +++ b/plugins/wasm-go/extensions/ai-proxy/main.go @@ -70,6 +70,9 @@ func onHttpRequestHeader(ctx wrapper.HttpContext, pluginConfig config.PluginConf ctx.SetContext(ctxKeyApiName, apiName) if handler, ok := activeProvider.(provider.RequestHeadersHandler); ok { + // Disable the route re-calculation since the plugin may modify some headers related to the chosen route. + ctx.DisableReroute() + action, err := handler.OnRequestHeaders(ctx, apiName, log) if err == nil { return action @@ -153,9 +156,6 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, pluginConfig config.PluginCo ctx.BufferResponseBody() } - // Disable the route re-calculation since the plugin may modify some headers related to the chosen route. - ctx.DisableReroute() - return types.ActionContinue }