Skip to content

Commit 4391e4d

Browse files
authored
Merge pull request #30 from omri-rulf/patch-1
docs: add troubleshooting section and geo-targeting notes
2 parents 533b617 + 2187bf0 commit 4391e4d

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const html = await client.scrapeUrl('https://example.com');
3030
console.log(html);
3131

3232
// Search the web
33-
const results = await client.search.google('pizza restaurants');
33+
const results = await client.search.google('pizza restaurants', { country: 'us' });
3434
console.log(results);
3535
```
3636

@@ -116,6 +116,9 @@ const results = await client.search.google('pizza', {
116116
format: 'json',
117117
});
118118
```
119+
> **Note:** If `country` is not specified, requests exit through an arbitrary
120+
> proxy location, so results may be geo-located to an unexpected country.
121+
> Always pass `country` when you need consistent, localized results.
119122
120123
### Platform scrapers
121124

@@ -337,6 +340,8 @@ BRIGHTDATA_BROWSERAPI_USERNAME=your_browser_username # Optional, for Browser API
337340
BRIGHTDATA_BROWSERAPI_PASSWORD=your_browser_password # Optional, for Browser API
338341
BRIGHTDATA_VERBOSE=1 # Optional, enable verbose logging
339342
```
343+
> **Tip:** When loading these from a `.env` file with `node --env-file=.env`,
344+
> note that variables already set in your shell take precedence over the file.
340345
341346
### Client Options
342347

@@ -414,6 +419,40 @@ try {
414419

415420
**Error types:** `ValidationError`, `AuthenticationError`, `ZoneError`, `NetworkError`, `NetworkTimeoutError`, `TimeoutError`, `APIError`, `DataNotReadyError`, `FSError`
416421

422+
## Troubleshooting
423+
424+
### Windows & corporate networks
425+
426+
| Problem | Fix |
427+
|---|---|
428+
| `npm.ps1 cannot be loaded because running scripts is disabled` (PowerShell) | Use **cmd** instead of PowerShell, or run `npm.cmd <command>`, or run `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned`. If overridden by Group Policy, contact your IT team. |
429+
| `SELF_SIGNED_CERT_IN_CHAIN` during `npm install` | Your network uses SSL inspection. Point npm to your corporate root certificate: `npm config set cafile "C:\path\to\corporate-root.cer"` |
430+
| Certificate errors at runtime | Set the env variable `NODE_EXTRA_CA_CERTS=C:\path\to\corporate-root.cer` so Node trusts your corporate certificate. |
431+
432+
### AuthenticationError: invalid API key
433+
434+
If you get this error, check the following in order:
435+
436+
1. **Verify the token itself** works, outside the SDK:
437+
```bash
438+
curl -H "Authorization: Bearer YOUR_TOKEN" https://api.brightdata.com/zone/get_active_zones
439+
```
440+
If this fails, generate a new API key with **admin** permissions in the
441+
[control panel](https://brightdata.com/cp/setting/users). Note the SDK needs
442+
an account-level API token — not a zone password.
443+
2. **Check for shell overrides.** Environment variables set in your shell take
444+
precedence over `.env` files loaded with `node --env-file=.env`. Run
445+
`set BRIGHTDATA` (Windows) or `env | grep BRIGHTDATA` (macOS/Linux) and clear
446+
any leftover values.
447+
3. **Check your `.env` file:** no quotes, no spaces around `=`, no trailing
448+
whitespace, and the token copied exactly (including dashes). Prefer LF line
449+
endings.
450+
4. **Print what actually loaded:**
451+
```js
452+
console.log(JSON.stringify(process.env.BRIGHTDATA_API_TOKEN));
453+
```
454+
Hidden characters like `\r` will be visible in the output.
455+
417456
## Support
418457

419458
For any issues, contact [Bright Data support](https://brightdata.com/contact), or open an issue in this repository.

0 commit comments

Comments
 (0)