I’m seeing something I’m not sure is correct. I’ve read the docs and from my understanding the first request should be an OPTIONS method that allows me to configure the pre-flight CORS settings. All good.
Then I should see POST and PATCH for uploading the file to my tus server. However, what I’m seeing is that a HEAD request is made before the POST and it errors with 404 because the file hasn’t been uploaded yet, obviously. The POST and subsequent PATCH requests succeed with status 200. The 404 error is thrown at my server with “The file for this url was not found”. This all makes sense to me because the POST upload hasn’t occurred yet. The issue is not because the url is different:
OPTIONS
/public/d706cbf3e39330a1cb974fd7d3e462d5
HEAD
/public/d706cbf3e39330a1cb974fd7d3e462d5
POST
/public/d706cbf3e39330a1cb974fd7d3e462d5
What could cause this? Shouldn’t the POST request be made before HEAD? I do not resume or pause this upload. I drag the file inside the dashboard and click upload, that’s it.
Here’s how I’m using uppy in react:
const [uppy] = useState(() => {
const uppyInstance = new Uppy({
restrictions: {
maxNumberOfFiles: 1,
allowedFileTypes: ['.png', '.jpg', '.jpeg', '.gif'],
maxFileSize: 10 * 1024 * 1024,
},
onBeforeUpload(files) {
for (const [key, file] of Object.entries(files)) {
uppyInstance.setFileMeta(key, {
name: file.name,
type: file.type,
contentType: file.type,
})
}
return true
},
}).use(Tus, {
endpoint: endpointUrl,
withCredentials: useCredentials,
})
return uppyInstance.on('complete', (result) => {
setAvatar(result.successful[0]?.uploadURL || '')
})
})