Open Larusyang opened 6 months ago
I use app router,but it seems the document doesn't provide details about how to use app router with cloudflare.
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'
I followed the documentation to configure with Cloudflare R2, It's saying some errors.
` import { APIRoute } from "next-s3-upload";
export default APIRoute.configure({ accessKeyId: process.env.CLOUDFLARE_R2_ACCESS_KEY_ID, secretAccessKey: process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY, bucket: "nextjs-file-upload", region: "ap-southeast-1", endpoint: https://${process.env.R2_ACCOUNT_ID}.r2.cloudflarestorage.com, }); `
ERROR:
⨯ Detected default export in 'D:\Documents\Next Projects\nextjs-s3-server-actions\app\api\cloudflare-next-s3-upload\route.ts'. Export a named export for each HTTP method instead.
⨯ No HTTP methods exported in 'D:\Documents\Next Projects\nextjs-s3-server-actions\app\api\cloudflare-next-s3-upload\route.ts'. Export a named export for each HTTP method.
Anyone can fix this error?
Since it use the same repo