Skip to content

Commit 87070a3

Browse files
authored
Add browser rendering faq (#17995)
1 parent aad7781 commit 87070a3

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/content/docs/browser-rendering/changelog.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Changelog
44
changelog_file_name:
55
- browser-rendering
66
sidebar:
7-
order: 8
7+
order: 9
88
head: []
99
description: Review recent changes to Worker Browser Rendering.
1010
---
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: FAQ
3+
pcx_content_type: faq
4+
sidebar:
5+
order: 8
6+
head:
7+
- tag: title
8+
content: Frequently asked questions about Cloudflare Browser Rendering
9+
---
10+
11+
import { GlossaryTooltip } from "~/components";
12+
13+
Below you will find answers to our most commonly asked questions. If you cannot find the answer you are looking for, refer to the [Discord](https://discord.cloudflare.com) to explore additional resources.
14+
15+
##### Uncaught (in response) TypeError: Cannot read properties of undefined (reading 'fetch')
16+
17+
Make sure that you are passing your Browser binding to the `puppeteer.launch` api and that you have [Workers for Platforms Paid plan](/cloudflare-for-platforms/workers-for-platforms/platform/pricing/).
18+
19+
##### Will browser rendering bypass Cloudflare's Bot Protection?
20+
21+
Browser rendering requests are always identified as bots by Cloudflare.
22+
23+
## Puppeteer
24+
25+
##### Code generation from strings disallowed for this context while using an Xpath selector
26+
27+
Currently it's not possible to use Xpath to select elements since this poses a security risk to Workers.
28+
29+
As an alternative try to use a css selector or `page.evaluate` for example:
30+
31+
```ts
32+
const innerHtml = await page.evaluate(() => {
33+
return (
34+
// @ts-ignore this runs on browser context
35+
new XPathEvaluator()
36+
.createExpression("/html/body/div/h1")
37+
// @ts-ignore this runs on browser context
38+
.evaluate(document, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue
39+
.innerHTML
40+
);
41+
});
42+
```
43+
44+
:::note
45+
46+
Keep in mind that `page.evaluate` can only return primitive types like strings, numbers, etc.
47+
48+
Returning an `HTMLElement` won't work.
49+
50+
:::

src/content/docs/browser-rendering/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { CardGrid, Description, LinkTitleCard, Plan, RelatedProduct } from "~/co
1313

1414
<Description>
1515

16-
Browser automation for [Cloudflare Workers](/workers/).
16+
Browser automation for [Cloudflare Workers](/workers/).
1717
</Description>
1818

1919
<Plan type="workers-paid" />

0 commit comments

Comments
 (0)