I ran into a small but annoying problem while deploying a Next.js MDX blog to Cloudflare Workers with OpenNext.
The blog worked locally. The build passed. OpenNext even listed the blog routes during the build.
Then I opened the deployed site, and the blog page was empty.
The issue was not MDX. It was not frontmatter. It was not a missing route. The real problem was that my blog code was still thinking like a normal Node.js app, while Cloudflare Workers runs from a bundled Worker output.
The Short Version
If your MDX blog works in next dev but shows empty pages or missing posts on Cloudflare Workers, check if you read blog files with node:fs at request time.
This is the safer pattern:
- Keep writing posts as
.mdxfiles. - Parse the files during the build.
- Generate a small TypeScript file with post metadata.
- Generate another TypeScript file that statically imports every MDX post.
- Render posts from that generated registry in production.
That way the Worker does not need to scan your content/blog folder at runtime.
SOCIAL SHARE CARD GENERATOR