question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pre-rendering in Cloudflare Workers

See original GitHub issue

vite-plugin-ssr/node/prerender.ts is currently not been designed to work in a Cloudflare Worker.

But, in principle, it should be possible to run pre-rendering in a Cloudflare Worker.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
brilloutcommented, Dec 16, 2021

Done.

Example:

I’d suggest following API:

import { prerender } from 'vite-plugin-ssr/cli'

// Analogous to `pageContextInit` in `renderPage()`.
const pageContextInit = {
  // Make Cloudflare Workers's `fetch()` available as `pageContext.fetch`.
  fetch: (...args) => fetch(...args),
}
const onPagePrerender = (filePath, fileContent) => {
  // We can do whatever we want with the prerendered page result
  // E.g. write `fileContent` to `/tmp/${filePath}`
}
await prerender({ pageContextInit, onPagePrerender })

@SherinBloemendaal Would that work for you?

0reactions
SherinBloemendaalcommented, Dec 20, 2021

No but it’s quick to implement. The main difficulty was to be able to run pre-rendering on Cloudflare Workers which now works.

Ok that would be very nice. If that feature is implemented, then we can start testing it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prerender Cloudflare worker - GitHub
Select your site on the Cloudflare dashboard. · Navigate through Workers -> Manage workers -> Create a worker . · Copy and paste...
Read more >
Serverless Rendering with Cloudflare Workers
Learning how to do server-side rendering at the network edge using Workers Sites, Wrangler, HTMLRewriter, and tools from the broader Workers ...
Read more >
Cloudflare Integration - Prerender.io
Our Cloudflare integration uses a simple worker implementation that routes requests between your site (probably your cached site) and ...
Read more >
Dynamic meta tags for bots and crawlers using Firebase and ...
Pre-rendering would be a good solution; route incoming requests based on the user agent, users get the site from the CDN and bots...
Read more >
Combine 2 blocks of javascript using 1 cloudflare worker
Basic settings */ // The API key visible on your Prerender ... agents that the worker will look for to // initiate prerendering...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found