ryanto / next-s3-upload

Upload files from your Next.js app to S3
https://next-s3-upload.codingvalue.com/
546 stars 76 forks source link

Can I use this for cloudflare R2 #183

Open Larusyang opened 3 months ago

Larusyang commented 3 months ago

Since it use the same repo

Larusyang commented 3 months ago

I use app router,but it seems the document doesn't provide details about how to use app router with cloudflare.

nico-limo commented 2 months ago

Hi, I am using it with cloudflare and pages but cloudflare require to run it on the EDGE. I don't know how to make it work that. Here is my config that works when the EDGE is not set

import { APIRoute } from 'next-s3-upload'

export default APIRoute.configure({ key(req) { const cid = req.body.cid as string return cid }, accessKeyId: process.env.R2_ACESSS_ID, secretAccessKey: process.env.R2_SECRET_ID, bucket: process.env.BUCKET, region: 'us-east-1', endpoint: https://${process.env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com,

})

export const runtime = 'edge'