Test script for Bright Data Unlocker in two modes:
- Unlocker REST API - Recommended for Cloudflare-protected sites
- Native proxy-based access - Using Unlocker zone with axios + HttpsProxyAgent
npm installSet environment variables (or use defaults in the script):
# For Unlocker API
export BRIGHT_DATA_API_KEY="your_api_key"
export BRIGHT_DATA_UNLOCKER_ZONE="web_unlocker1"
# For native proxy access
export BRIGHT_DATA_UNLOCKER_PROXY_USERNAME="brd-customer-ACCOUNT_ID-zone-ZONE_NAME"
export BRIGHT_DATA_UNLOCKER_PROXY_PASSWORD="your_password"# Default mode (uses API)
node test-brightdata-proxy.js https://forum.opencart.com/feed/forum/2
# Explicit API mode
node test-brightdata-proxy.js --unlocker-api https://forum.opencart.com/feed/forum/2
# Or use npm script
npm run test:api https://forum.opencart.com/feed/forum/2# Native proxy with Unlocker zone
node test-brightdata-proxy.js --unlocker-native https://forum.opencart.com/feed/forum/2
# Or use npm script
npm run test:native https://forum.opencart.com/feed/forum/2Start the server:
npm startThe server will run on port 3000 (or PORT environment variable).
Health Check:
GET /healthTest Endpoint (GET) - Returns JSON with preview (or full content when full=true):
GET /test?url=https://forum.opencart.com/feed/forum/2&mode=api
GET /test?url=https://forum.opencart.com/feed/forum/2&mode=native
GET /test?url=https://forum.opencart.com/feed/forum/2&mode=api&full=true # Include full content in JSONFetch Endpoint (GET) - Returns full raw content (XML, HTML, etc.):
GET /fetch?url=https://forum.opencart.com/feed/forum/2&mode=api
GET /fetch?url=https://forum.opencart.com/feed/forum/2&mode=nativeTest Endpoint (POST):
POST /test
Content-Type: application/json
{
"url": "https://forum.opencart.com/feed/forum/2",
"mode": "api",
"full": true // optional - include full content in response
}Fetch Endpoint (POST):
POST /fetch
Content-Type: application/json
{
"url": "https://forum.opencart.com/feed/forum/2",
"mode": "api"
}Using curl:
# Health check
curl https://your-render-url.onrender.com/health
# Test with API mode
curl "https://your-render-url.onrender.com/test?url=https://forum.opencart.com/feed/forum/2&mode=api"
# Test with native proxy mode
curl "https://your-render-url.onrender.com/test?url=https://forum.opencart.com/feed/forum/2&mode=native"
# POST request
curl -X POST https://your-render-url.onrender.com/test \
-H "Content-Type: application/json" \
-d '{"url": "https://forum.opencart.com/feed/forum/2", "mode": "api"}'Using browser:
https://your-render-url.onrender.com/test?url=https://forum.opencart.com/feed/forum/2&mode=api
{
"mode": "api",
"url": "https://forum.opencart.com/feed/forum/2",
"success": true,
"status": 200,
"contentLength": 12345,
"contentPreview": "<?xml version=\"1.0\"...",
"isXml": true,
"hasCloudflareChallenge": false,
"logs": [...]
}--unlocker-apior--unlocker- Use Bright Data Unlocker REST API--unlocker-nativeor--unlocker-axios- Use native proxy with Unlocker zone--help- Show help message
node test-brightdata-proxy.js --unlocker-api https://forum.opencart.com/feed/forum/2node test-brightdata-proxy.js --unlocker-native https://forum.opencart.com/feed/forum/2curl -i --proxy brd.superproxy.io:33335 \
--proxy-user brd-customer-hl_7342b85c-zone-web_unlocker1:gp2p3zbiz07q -k \
"https://forum.opencart.com/feed/forum/2"- Connect your GitHub repository to Render
- Set environment variables in Render dashboard:
BRIGHT_DATA_API_KEYBRIGHT_DATA_UNLOCKER_ZONE(optional, defaults toweb_unlocker1)BRIGHT_DATA_UNLOCKER_PROXY_USERNAME(for native mode)BRIGHT_DATA_UNLOCKER_PROXY_PASSWORD(for native mode)
- Render will automatically detect
package.jsonand runnpm start - Your service will be available at
https://your-service.onrender.com
MIT