Initial commit
This commit is contained in:
116
templates/wrangler-browser-config.jsonc
Normal file
116
templates/wrangler-browser-config.jsonc
Normal file
@@ -0,0 +1,116 @@
|
||||
// Complete wrangler.jsonc configuration for Browser Rendering
|
||||
{
|
||||
"name": "browser-worker",
|
||||
"main": "src/index.ts",
|
||||
"compatibility_date": "2023-03-14",
|
||||
|
||||
// REQUIRED: nodejs_compat flag for Browser Rendering
|
||||
"compatibility_flags": [
|
||||
"nodejs_compat"
|
||||
],
|
||||
|
||||
// Browser binding (required)
|
||||
"browser": {
|
||||
"binding": "MYBROWSER"
|
||||
// Optional: Use real headless browser during local development
|
||||
// "remote": true
|
||||
},
|
||||
|
||||
// Optional: KV for caching screenshots/PDFs
|
||||
// Create with: npx wrangler kv namespace create SCREENSHOT_CACHE
|
||||
// npx wrangler kv namespace create SCREENSHOT_CACHE --preview
|
||||
"kv_namespaces": [
|
||||
{
|
||||
"binding": "SCREENSHOT_CACHE",
|
||||
"id": "YOUR_KV_ID", // Replace with actual ID
|
||||
"preview_id": "YOUR_PREVIEW_ID" // Replace with actual preview ID
|
||||
}
|
||||
],
|
||||
|
||||
// Optional: R2 for storing generated files
|
||||
// Create with: npx wrangler r2 bucket create browser-files
|
||||
"r2_buckets": [
|
||||
{
|
||||
"binding": "BROWSER_FILES",
|
||||
"bucket_name": "browser-files"
|
||||
}
|
||||
],
|
||||
|
||||
// Optional: AI binding for AI-enhanced scraping
|
||||
"ai": {
|
||||
"binding": "AI"
|
||||
},
|
||||
|
||||
// Optional: D1 for storing scraping results
|
||||
// Create with: npx wrangler d1 create browser-db
|
||||
"d1_databases": [
|
||||
{
|
||||
"binding": "DB",
|
||||
"database_name": "browser-db",
|
||||
"database_id": "YOUR_DB_ID"
|
||||
}
|
||||
],
|
||||
|
||||
// Optional: Environment variables
|
||||
"vars": {
|
||||
"ENVIRONMENT": "production"
|
||||
},
|
||||
|
||||
// Optional: Secrets (set with: npx wrangler secret put SECRET_NAME)
|
||||
// "secrets": ["API_KEY"]
|
||||
|
||||
// Optional: Custom routes for production
|
||||
// "routes": [
|
||||
// {
|
||||
// "pattern": "browser.example.com/*",
|
||||
// "zone_name": "example.com"
|
||||
// }
|
||||
// ]
|
||||
}
|
||||
|
||||
/**
|
||||
* Key Configuration Notes:
|
||||
*
|
||||
* 1. nodejs_compat flag is REQUIRED
|
||||
* - Browser Rendering needs Node.js APIs
|
||||
* - Automatically enables nodejs_compat_v2 if compatibility_date >= 2024-09-23
|
||||
*
|
||||
* 2. Browser binding name
|
||||
* - Use "MYBROWSER" or any name you prefer
|
||||
* - Reference in code: env.MYBROWSER
|
||||
*
|
||||
* 3. Remote binding for local development
|
||||
* - "remote": true connects to real headless browser
|
||||
* - Useful if hitting 1MB request limit in local dev
|
||||
* - Remove for production (not needed)
|
||||
*
|
||||
* 4. KV for caching
|
||||
* - Highly recommended for production screenshot services
|
||||
* - Reduces browser usage and costs
|
||||
* - Cache TTL: typically 1-24 hours
|
||||
*
|
||||
* 5. R2 for file storage
|
||||
* - Store generated PDFs or screenshots long-term
|
||||
* - Cheaper than KV for large files
|
||||
* - Use presigned URLs for downloads
|
||||
*
|
||||
* 6. AI binding
|
||||
* - Optional: for AI-enhanced scraping
|
||||
* - Requires Workers Paid plan
|
||||
* - See cloudflare-workers-ai skill
|
||||
*
|
||||
* 7. D1 database
|
||||
* - Optional: store scraping metadata
|
||||
* - Track URLs, timestamps, status
|
||||
* - See cloudflare-d1 skill
|
||||
*
|
||||
* Commands:
|
||||
* npx wrangler dev # Local development
|
||||
* npx wrangler deploy # Deploy to production
|
||||
* npx wrangler tail # View logs
|
||||
*
|
||||
* See also:
|
||||
* - cloudflare-worker-base skill for complete Worker setup
|
||||
* - cloudflare-kv skill for KV caching patterns
|
||||
* - cloudflare-r2 skill for R2 storage patterns
|
||||
*/
|
||||
Reference in New Issue
Block a user