storage: Cannot upload any file over 6MB to self-hosted supabase storage via dashboard
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
When uploading a file greater than 6MB in size to storage via the supabase dashboard in a self-hosted instance I receive the following error:
Failed to upload 6_3mb.pdf: tus: failed to resume upload, caused by [object ProgressEvent], originated from request (method: HEAD, url: http://localhost/upload/resumable/cHN5Y2hvc29jaWFsX2NvbnRlbnQvRkdIIGJ1c2luZXNzIGNhcmRfMjAyNDA4MTkgY29weSA2LnppcC9hMjNmYTM5Yy1kZmI0LTRhMjUtYjQzYS1iMDU2OGY2MGM4NGU, response code: n/a, response text: n/a, request id: n/a)
While the file is uploading, I receive this error multiple times in the browser console
HEAD http://localhost/upload/resumable/cHN5Y2hvc29jaWFsX2NvbnRlbnQvRkdIIGJ1c2luZXNzIGNhcmRfMjAyNDA4MTkgY29weSA2LnppcC9hMjNmYTM5Yy1kZmI0LTRhMjUtYjQzYS1iMDU2OGY2MGM4NGU net::ERR_CONNECTION_REFUSED
I made sure to pull the latest docker images. This does not resolve the error.
To Reproduce
- Create a file that is 6MB in size
- Go to the self-hosted supabase dashboard: localhost:8000
- Go to storage, and upload the file
- It will show its uploading for a moment, then error out with the error above.
Expected behavior
Files up to 50MB should be able to be uploaded.
Screenshots
While uploading
Error
System information
- OS: macOS
- Browser (if applies): chrome
- Version of supabase docker compose: 3.8
- Version of Node.js: v18.19.0
Additional information
- I have tried this with other files, not just the one I am testing with. I receive the same error for anything over 6MB
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 7
- Comments: 19
looks like it’s already fixed in storage, but has not yet been fully updated to docker-compose of studio.
which this patch upload works for me locally
Hope it works for you.
if you add the following to kong section:
as well as the following to the storage section:
it all works without the need to alter kongs ports or alter the kong.yaml
ofc you change port mappings as required
For me just adding
NODE_ENV=productionandREQUEST_ALLOW_X_FORWARDED_PATH: truetosupabase-storageas well asKONG_PORT_MAPS: "443:8000"tosupabase-kongdid work too. I am usingsupabase/storage-api:v1.22.17andkong:2.8.1together with Traefik as reverse proxy.Important hint during testing: TUS by default stores your generated upload URLs in browser’s local storage. Therefore, when changing configurations and then retry uploading the same file, the previous URL is reused, which therefore might not reflect the changes you just made. So don’t forget to delete all
tus:*local storage entries before retrying!I spend a full day on this, tried every possible fix I could find. I couldn’t get rid of the
8000port number in the request, so I used it! My dirty hack:kong.yml
It’s ugly AF but it works and I can finally go to sleep.
P.S. Kong might be a great Enterprise choice but the FOSS version is limited and most people are not familiar with it. I’m pretty sure this bug is left in here on purpose (you can find issues over a year ago!) while the SaaS uses
request-transformer-advancedto fix this in a single rule…storage is returning an invalid location header
request sent to
https://supabase.domain.com/storage/v1/upload/resumableresponse contains Location header ofhttp://supabase.domain.com:8000/upload/resumable/............this is then set in local storage where uploads are then tried to send to:this then causes an error either due to content mismatch (trying to post to http from https or 404 since its trying to send to an invalid port plus missing /storage/v1)
i assume the bug is in here? https://github.com/supabase/storage/blob/f950fc4a6afd3cbde39d4e7f35b9df42b895b4dc/src/http/routes/tus/lifecycle.ts#L86 the request comes in from kong which is http… :8000 and no path prefix of /storage/v1
this but i had to set the TUS_URL_PATH to /storage/v1/upload/resumable in docker-compose.yml for it to work properly
@phatdinhvn for
Forwarded: proto=httpsyou can instead set
NODE_ENV=productionin storage section of compose it will do the same thingI have to modify as below to work smoothly: set env
KONG_PORT_MAPSis443:8000will remove:8000fromhttp://my.domain.com:8000/set envREQUEST_ALLOW_X_FORWARDED_PATHistrueand add header'Forwarded: proto=https'will forwardhttp://my.domain.com/tohttps://my.domain.com/and set envTUS_URL_PATHisupload/resumablefor storage-api to append urlhttps://my.domain.com/storage/v1/upload/resumableRestart kong and storage container. Clear cookies, caches on your browser.