fix(plugins): avoid Chi RouteContext pollution by using http.NewRequest (#4713)
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -93,8 +93,12 @@ func (s *subsonicAPIServiceImpl) Call(ctx context.Context, req *subsonicapi.Call
|
|||||||
RawQuery: query.Encode(),
|
RawQuery: query.Encode(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create HTTP request with internal authentication
|
// Create HTTP request with a fresh context to avoid Chi RouteContext pollution.
|
||||||
httpReq, err := http.NewRequestWithContext(ctx, "GET", finalURL.String(), nil)
|
// Using http.NewRequest (instead of http.NewRequestWithContext) ensures the internal
|
||||||
|
// SubsonicAPI call doesn't inherit routing information from the parent handler,
|
||||||
|
// which would cause Chi to invoke the wrong handler. Authentication context is
|
||||||
|
// explicitly added in the next step via request.WithInternalAuth.
|
||||||
|
httpReq, err := http.NewRequest("GET", finalURL.String(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &subsonicapi.CallResponse{
|
return &subsonicapi.CallResponse{
|
||||||
Error: fmt.Sprintf("failed to create HTTP request: %v", err),
|
Error: fmt.Sprintf("failed to create HTTP request: %v", err),
|
||||||
|
|||||||
Reference in New Issue
Block a user