fix: Location header on TUS endpoint (#5302)

This commit is contained in:
Henrique Dias 2025-07-17 18:06:59 +02:00 committed by GitHub
parent d61110e4d7
commit 607f5708a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"net/url"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -147,9 +148,12 @@ func tusPostHandler() handleFunc {
// Enables the user to utilize the PATCH endpoint for uploading file data // Enables the user to utilize the PATCH endpoint for uploading file data
registerUpload(file.RealPath(), uploadLength) registerUpload(file.RealPath(), uploadLength)
// Signal the frontend to reuse the current request URL path, err := url.JoinPath("/", d.server.BaseURL, "/api/tus", r.URL.Path)
w.Header().Set("Location", "") if err != nil {
return http.StatusBadRequest, fmt.Errorf("invalid path: %w", err)
}
w.Header().Set("Location", path)
return http.StatusCreated, nil return http.StatusCreated, nil
}) })
} }