router icon indicating copy to clipboard operation
router copied to clipboard

Nginx 502 Bad Gateway error when proxying prerendered pages with Cloudflare Pages

Open mladenovic-13 opened this issue 7 months ago • 0 comments

Which project does this relate to?

Start

Describe the bug

When enabling prerendering for marketing pages in a TanStack Start application deployed to Cloudflare Pages, nginx reverse proxy returns 502 Bad Gateway errors when accessing these prerendered routes.

Your Example Website or App

/

Steps to Reproduce the Bug or Issue

  1. Enable prerendering in vite.config.ts:
tanstackStart({
  target: 'cloudflare-pages',
  pages: [
    { path: '/', prerender: { enabled: true, crawlLinks: false } },
    { path: '/about-us', prerender: { enabled: true, crawlLinks: false } },
    { path: '/careers', prerender: { enabled: true, crawlLinks: false } },
    // ... other marketing pages
  ],
})
  1. Build the application: npm run build
  2. Deploy to Cloudflare Pages
  3. Set up nginx reverse proxy to Cloudflare Pages worker
  4. Access any prerendered route (e.g., /about-us)

Expected behavior

Prerendered pages should be served correctly through nginx proxy.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome

Additional context

No response

mladenovic-13 avatar Jun 11 '25 21:06 mladenovic-13