diff --git a/weed/admin/static/js/admin.js b/weed/admin/static/js/admin.js index 2633cb5b2..1160790b5 100644 --- a/weed/admin/static/js/admin.js +++ b/weed/admin/static/js/admin.js @@ -1267,7 +1267,7 @@ async function submitUploadFile() { }); // Send request - xhr.open('POST', '/api/files/upload'); + xhr.open('POST', basePath('/api/files/upload')); xhr.send(formData); } catch (error) { @@ -1320,7 +1320,7 @@ function exportFileList() { // Download file function downloadFile(filePath) { // Create download link using admin API - const downloadUrl = `/api/files/download?path=${encodeURIComponent(filePath)}`; + const downloadUrl = basePath(`/api/files/download?path=${encodeURIComponent(filePath)}`); window.open(downloadUrl, '_blank'); } @@ -1786,7 +1786,7 @@ function createFileViewerContent(file, content) { if (file.mime.startsWith('image/')) { return `
- ${file.name}
`; @@ -1804,7 +1804,7 @@ function createFileViewerContent(file, content) { } else if (file.mime === 'application/pdf') { return `
-
`; diff --git a/weed/command/admin.go b/weed/command/admin.go index fca5524e1..31ddd7a2c 100644 --- a/weed/command/admin.go +++ b/weed/command/admin.go @@ -392,7 +392,19 @@ func startAdminServer(ctx context.Context, options AdminOptions, enableUI bool, addr := fmt.Sprintf(":%d", *options.port) var handler http.Handler = r if urlPrefix != "" { - handler = http.StripPrefix(urlPrefix, r) + stripped := http.StripPrefix(urlPrefix, r) + handler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + // Redirect /prefix (no trailing slash) to /prefix/ + if req.URL.Path == urlPrefix { + target := urlPrefix + "/" + if req.URL.RawQuery != "" { + target += "?" + req.URL.RawQuery + } + http.Redirect(w, req, target, http.StatusFound) + return + } + stripped.ServeHTTP(w, req) + }) } server := &http.Server{ Addr: addr,