Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use this for cloudflare R2 #183

Open
Larusyang opened this issue May 9, 2024 · 3 comments
Open

Can I use this for cloudflare R2 #183

Larusyang opened this issue May 9, 2024 · 3 comments

Comments

@Larusyang
Copy link

Since it use the same repo

@Larusyang
Copy link
Author

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

@nico-limo
Copy link

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'

@imvinojanv
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants