uppy icon indicating copy to clipboard operation
uppy copied to clipboard

Uppy throws error "tus: invalid or missing Location header, originated from request" even though location header is present

Open Felix-Seip opened this issue 1 year ago • 4 comments

Initial checklist

  • [X] I understand this is a bug report and questions should be posted in the Community Forum
  • [X] I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

https://github.com/tomdesair/tus-java-server-spring-demo

Steps to reproduce

I am currently working on a project that needs to implement the TUS protocol, because we are uploading large files (20+ GB) that need to be interruptable.

We have a server that implements the TUS protocol using the servlet implementation from Tom Desair (https://github.com/tomdesair/tus-java-server). Before we start customizing the servlet to fit our needs, we tested the servlet out using the Spring Boot example that is mentioned in the README of the servlet repository. This example works just fine using the provided java client and the upload succeeds.

However, when we tried communicating with the server using the Uppy CDN example mentioned in the Getting Started Guide, we are receiving the following error when creating an upload resource on the POST request: Failed to upload 03ffbb3f-b13f-4fe7-b09b-d62806b1203c.jpg tus: invalid or missing Location header, originated from request (method: POST, url: http://localhost:8080/api/upload, response code: 201, response text: , request id: n/a)

The weird thing is however that the response sent by the server back to the CDN example contains the following headers:

HTTP/1.1 201 
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: *
Tus-Resumable: 1.0.0
Location: http://localhost:8080/api/upload/6c51a7b3-1fe0-44c0-af5d-5aa516ec140e
Content-Length: 0
Date: Tue, 19 Jul 2022 12:02:58 GMT
Keep-Alive: timeout=60
Connection: keep-alive

To reproduce this error, do the following:

  1. Checkout the example repository: https://github.com/tomdesair/tus-java-server-spring-demo
  2. Setup the CDN example from the Getting Started page: https://uppy.io/docs/
  3. Start the Spring Boot application
  4. Change the upload URL of the CDN example to http://localhost:8080/api/upload
  5. Upload a file using the CDN example and observe the network tab

It is clearly visible that the Location header is present. Can someone explain why we are receiving this error? To us, it seems like it is a bug within Uppy itself, but we may be wrong about that and just doing something wrong.

Expected behavior

The file should be uploaded correctly without the error Failed to upload 03ffbb3f-b13f-4fe7-b09b-d62806b1203c.jpg tus: invalid or missing Location header, originated from request (method: POST, url: http://localhost:8080/api/upload, response code: 201, response text: , request id: n/a) being thrown

Actual behavior

Uppy fails to find the Location header and throws the following error: Failed to upload 03ffbb3f-b13f-4fe7-b09b-d62806b1203c.jpg tus: invalid or missing Location header, originated from request (method: POST, url: http://localhost:8080/api/upload, response code: 201, response text: , request id: n/a)

Felix-Seip avatar Jul 19 '22 12:07 Felix-Seip

Update: the upload works with with Uppy Version 1.0.0 and the error that the Location header can't be found in the response is no longer present. Could this just be a problem with the newest version of Uppy?

Felix-Seip avatar Jul 20 '22 11:07 Felix-Seip

Hi, I haven't seen this error before with the latest Uppy versions for tus-node-server and tusd. Which leaves me to believe it is in fact the java server doing something incorrect, even though it fails on the client. However, I don't see anything wrong with the location header. Maybe @Acconut has some clues.

Murderlon avatar Jul 20 '22 11:07 Murderlon

Could you try the same upload with tusd or our test tusd instance here: https://uppy.io/examples/dashboard/

arturi avatar Jul 21 '22 13:07 arturi

@Felix-Seip For further investigate please generate a HAR file (see https://www.medianova.com/en-blog/a-step-by-step-guide-to-generating-a-har-file/) after trying to upload to your own tus server. Then we can see which requests occurred.

Acconut avatar Jul 22 '22 08:07 Acconut

Closing this, but feel free to continue the discussion

Murderlon avatar Sep 14 '22 08:09 Murderlon