Cloudflare R2 instructions
Hello!
I'm having some problem getting this to work with Cloudflare R2.
I've signed up for R2 and created auth tokens according to: https://developers.cloudflare.com/r2/data-access/s3-api/tokens Then I created a bucket in the Cloudflare dashboard. I've also set all environment variables.
I get the following error: InvalidClientTokenId: The security token included in the request is invalid.
I guess I must somehow tell next-s3-upload to the the correct URL? The docs says this:
The S3 endpoint is available via https://<ACCOUNT_ID>.r2.cloudflarestorage.com endpoint.
Probably something like this is needed: https://github.com/ryanto/next-s3-upload/pull/97
Hey thanks for the issue! So currently this library does not support non AWS hosts because it relies on AWS-STS. It's silly, we should support non AWS hosts as this question comes up all the time!
I have an idea for how we can support R2, just need to find some time to get it done. I'll update here.
Ok, I took a shot at this tonight, but was not able to get browser based uploads to R2 using pre-signed requests working. From the R2 docs it looks like this should work, but I keep running into CORS errors. From googling it looks like others are running into this issue as well: https://community.cloudflare.com/t/problem-with-settings-cors-policies-on-r2/432339/11
If you've got a demo or proof of concept that has uploads working with R2 I'd love to see it! With a working example I should be able to make next-s3-upload support R2.
In the mean time I'm going to close this issue, but I'll keep my eye on that cloudflare support thread and see if they post any answers.
Uploads to Cloudflare R2 are now supported in 0.2.8.
Docs here: https://next-s3-upload.codingvalue.com/other-providers
Thanks! 🙏🙏🙏