Solving Cloudflare Build Issues: Now My Local-Only Admin Dashboard Runs Locally Without an Adapter
Deploying my latest update unraveled a problem: Cloudflare couldn’t build the site. The error was: “No adapter installed for server-rendered pages.”
Locally, everything runs fine - Astro, Tailwind, Engine? (Thinking of calling it that) - all working. But production builds were failing, and I needed a quick solution.
Initial Options Considered
The first obvious solution was to spin up a separate local server to handle API routes. That would have worked, but it felt heavy-handed: I didn’t want to maintain two processes just for local development. Plus, it didn’t address the underlying desire to keep Engine drop-in and flexible.
Another idea was to force SSG everywhere and avoid server-side routes entirely, but that conflicted with the admin interface, which needs live read/write access to Markdown files during development.
The Vite Plugin Approach
Somehow I arrived at the solution of using Vite’s plugin system. I built a simple plugin that hooks into the dev server, intercepts API requests, and serves the posts API locally. This approach has several advantages:
- No separate server process is required.
- Dev experience is seamless - posts can be created, edited, and previewed in real time.
- Production builds remain fully static without hitting server routes.
- Engine as a its own Project/Folder.
Effectively, the API routes only exist in development, while pre-rendered pages work for SSG.
The One Line That Caused Cloudflare to Fail
Even after the plugin, Cloudflare still complained. The culprit was a single line in the admin page:
export const prerender = true
By default, Astro tries to prerender all pages marked as true (Which is what they call Static Site Generation (SGG)). The admin page, however, is dynamic in dev, needing access to the API plugin. Setting prerender = false solved the build error: production now ignores the admin route, which only functions in dev with the Vite plugin active.
In a Nutshell
- Engine can now run locally with full editing and preview support, without a separate server.
- Production builds are static and free of server-rendered routes.
