Uppy.min.js:1 [Uppy] [08:34:21] Failed to upload test1.pdf tus: invalid or missing Location header, originated from request

Hi
I am using combination of tusdotnet and uppy for uploading file.
Uppy on frontend and tusdotnet in backend (setting up in dotnet core startup as middleware). For same domain, when Frontend Uppy and Backend Tusdotnet are in same web application, it works fine.
But i want to keep tusdotnet in my web api, and Uppy on different domain as frontend.
And it failed to upload file. I have Enable CORS on both ends
I get these errors in developer tool;
uppy.min.js:1 Refused to get unsafe header “Location”

uppy.min.js:1 [Uppy] [08:34:21] Failed to upload test1.pdf tus: invalid or missing Location header, originated from request (response code: 201, response text: )

error with file: uppy-test1/pdf-1e-application/pdf-25000000-1594654313511

error message: Error: tus: invalid or missing Location header, originated from request (response code: 201, response text: )
at new t (uppy.min.js:1)
at e.value (uppy.min.js:1)
at XMLHttpRequest.t.onload (uppy.min.js:1)

Network Headers:

  1. Request URL:

http://localhost:4200/files/

  1. Request Method:

POST

  1. Status Code:

201 Created

  1. Remote Address:
  1. Referrer Policy:

no-referrer-when-downgrade

  1. Response Headersview source

  2. Access-Control-Allow-Origin:

  3. Content-Length:

0

  1. Date:

Thu, 23 Jul 2020 07:34:01 GMT

  1. Location:

/files/53e5d9e6de0248869bdb8897f61a5bf9

  1. Server:

Kestrel

  1. Tus-Resumable:

1.0.0

  1. Upload-Expires:

Thu, 23 Jul 2020 08:04:02 GMT

  1. Request Headersview source

  2. Accept:

4./*

  1. Accept-Encoding:

gzip, deflate, br

  1. Accept-Language:

en-US,en;q=0.9

  1. Connection:

keep-alive

  1. Content-Length:

0

  1. Host:

localhost:4200

  1. Origin:

https://localhost:5001

  1. Sec-Fetch-Dest:

empty

  1. Sec-Fetch-Mode:

cors

  1. Sec-Fetch-Site:

cross-site

  1. Tus-Resumable:

1.0.0

  1. Upload-Length:

25000000

  1. Upload-Metadata:

relativePath bnVsbA==,name dGVzdDEucGRm,type YXBwbGljYXRpb24vcGRm,filetype YXBwbGljYXRpb24vcGRm,filename dGVzdDEucGRm

  1. User-Agent:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36

Its not happening if i set Endpoint = “https://master.tus.io/files/” in Uppy settings for tus

Found solution for this:
Just add this while setting CORS setting in Startup file in on Tusdotnet end.
.WithExposedHeaders(CorsHelper.GetExposedHeaders())

e.g
services.AddCors(options =>
{
options.AddPolicy(“CorsPolicy”,
builder => builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()
.WithExposedHeaders(CorsHelper.GetExposedHeaders()));
});

1 Like