© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•8mo ago•
9 replies
Ryan

How to access local HTML file with Puppeteer?

I have a Cloudflare Worker that I want to take a screenshot of a local HTML file. I for the love of god can't figure how to open that file or access any of the file system on a worker.

I'm using Cloudflare Browser Rendering to and Cloudflare's fork of Puppeteer.

I tried to hard code the HTML and CSS in my JS but I found that I can't easily hard code in a font file which I need. Any ideas?

async function generateScreenshot(env) {
    const browser = await puppeteer.launch(env.MYBROWSER);
    const page = await browser.newPage();

    // How do I access my HTML including CSS, fonts, and images?
    await page.goto('src/html/index.html');

    const screenshot = await page.screenshot();

    return screenshot;
}
async function generateScreenshot(env) {
    const browser = await puppeteer.launch(env.MYBROWSER);
    const page = await browser.newPage();

    // How do I access my HTML including CSS, fonts, and images?
    await page.goto('src/html/index.html');

    const screenshot = await page.screenshot();

    return screenshot;
}


Here is the file structure I'm dealing with:
src/
│   index.js
└───html/
    │   index.html
    │   style.css
    ├───fonts/
    │       customFont.woff2
    └───images/
            attachment.png
src/
│   index.js
└───html/
    │   index.html
    │   style.css
    ├───fonts/
    │       customFont.woff2
    └───images/
            attachment.png


Let me know if any other information is needed.
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to access secrets from .ENV file globally on local server ?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
4w ago
how do i call js file from html file?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
14mo ago
Puppeteer: How to install package from WebUI?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
5mo ago