Skip to content

feat: verify Cloudflare R2 setup #24

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

Merged
merged 9 commits into from
Jun 5, 2025
Merged

feat: verify Cloudflare R2 setup #24

merged 9 commits into from
Jun 5, 2025

Conversation

nullcoder
Copy link
Owner

Summary

  • Verified Cloudflare R2 bucket setup and accessibility
  • Created comprehensive test endpoints for R2 operations
  • Added documentation for R2 setup and troubleshooting

Changes

  • ✅ Created /api/r2-test endpoints for testing R2 operations (GET/POST/DELETE)
  • ✅ Added R2Test UI component for interactive testing
  • ✅ Documented R2 setup process in docs/R2_SETUP.md
  • ✅ Extended CloudflareEnv interface to include GHOSTPASTE_BUCKET binding
  • ✅ Tested both text and binary data read/write operations

Testing

  • R2 bucket ghostpaste-bucket exists and is accessible
  • Test endpoints demonstrate successful read/write/delete operations
  • Binary data handling verified with Uint8Array tests
  • Proper error handling for missing bindings

Notes

  • The test component is temporarily added to the home page for verification
  • Uses @opennextjs/cloudflare for accessing Cloudflare bindings
  • Tests should be run with npm run preview (not npm run dev)

Closes #12

🤖 Generated with Claude Code

Copy link

cloudflare-workers-and-pages bot commented Jun 5, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ghostpaste 37e09bf Visit preview Jun 05 2025, 03:21 PM

nullcoder and others added 8 commits June 5, 2025 08:13
- Created R2 test API endpoints for GET/POST/DELETE operations
- Added R2Test component for UI testing
- Documented R2 setup process and troubleshooting
- Extended CloudflareEnv interface for GHOSTPASTE_BUCKET binding
- Tested both text and binary data operations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <claude@ghostpaste.dev>
Co-Authored-By: Claude <claude@ghostpaste.dev>
- Added initOpenNextCloudflareForDev to next.config.ts
- Updated R2_SETUP.md with development mode instructions
- Fixes R2 access in npm run dev mode

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <claude@ghostpaste.dev>
Co-Authored-By: Claude <claude@ghostpaste.dev>
- Convert Date objects to ISO strings for JSON serialization
- Improve error message handling with proper type checking
- Ensure all response data is serializable

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <claude@ghostpaste.dev>
Co-Authored-By: Claude <claude@ghostpaste.dev>
- Remove metadata from response to avoid non-POJO serialization
- Add debug logging to identify problematic objects
- Use spread operator to ensure plain object for customMetadata

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <claude@ghostpaste.dev>
Co-Authored-By: Claude <claude@ghostpaste.dev>
- Remove all complex objects and metadata from responses
- Simplify to basic success/failure messages
- Ensure all returned data is primitive types only
- Add nested try-catch for better error isolation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <claude@ghostpaste.dev>
Co-Authored-By: Claude <claude@ghostpaste.dev>
- Use intersection type (CloudflareEnv & Env) for proper typing
- Remove global interface extension as it's not needed
- Maintain type safety for R2 bucket binding

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <claude@ghostpaste.dev>
Co-Authored-By: Claude <claude@ghostpaste.dev>
- Run wrangler types with --env-interface CloudflareEnv flag
- Remove manual type casting as CloudflareEnv now includes our bindings
- Update npm script to always use the correct flag
- Follow @opennextjs/cloudflare documentation best practices

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <claude@ghostpaste.dev>
Co-Authored-By: Claude <claude@ghostpaste.dev>
…tion

Co-Authored-By: Claude <claude@ghostpaste.dev>
@nullcoder nullcoder force-pushed the feat/verify-r2-setup branch from 1bf8ba8 to 473ca82 Compare June 5, 2025 15:14
OpenNext requires edge runtime functions to be in separate files.
All API routes run on edge runtime by default with @opennextjs/cloudflare.

Co-Authored-By: Claude <claude@ghostpaste.dev>
@nullcoder nullcoder merged commit ea4c314 into main Jun 5, 2025
1 check passed
@nullcoder nullcoder deleted the feat/verify-r2-setup branch June 5, 2025 15:22
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

Successfully merging this pull request may close these issues.

Verify Cloudflare R2 setup
1 participant