From 9072cbce340da55477906f5419a4cfb6d6937dc0 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Sun, 13 Jul 2025 14:29:27 -0300 Subject: [PATCH] fix: invalid path when uploading files --- frontend/src/api/tus.ts | 4 ++-- http/tus_handlers.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/api/tus.ts b/frontend/src/api/tus.ts index 64efe69a..fbfef4da 100644 --- a/frontend/src/api/tus.ts +++ b/frontend/src/api/tus.ts @@ -1,5 +1,5 @@ import * as tus from "tus-js-client"; -import { baseURL, tusEndpoint, tusSettings } from "@/utils/constants"; +import { baseURL, tusEndpoint, tusSettings, origin } from "@/utils/constants"; import { useAuthStore } from "@/stores/auth"; import { useUploadStore } from "@/stores/upload"; import { removePrefix } from "@/api/utils"; @@ -35,7 +35,7 @@ export async function upload( } return new Promise((resolve, reject) => { const upload = new tus.Upload(content, { - endpoint: `${baseURL}${resourcePath}`, + endpoint: `${origin}${baseURL}${resourcePath}`, chunkSize: tusSettings.chunkSize, retryDelays: computeRetryDelays(tusSettings), parallelUploads: 1, diff --git a/http/tus_handlers.go b/http/tus_handlers.go index c5eec9ad..002d78b5 100644 --- a/http/tus_handlers.go +++ b/http/tus_handlers.go @@ -147,7 +147,8 @@ func tusPostHandler() handleFunc { // Enables the user to utilize the PATCH endpoint for uploading file data registerUpload(file.RealPath(), uploadLength) - w.Header().Set("Location", "/api/tus/"+r.URL.Path) + // Signal the frontend to reuse the current request URL + w.Header().Set("Location", "") return http.StatusCreated, nil })