Making Dynamic MDX Blogs Work with OpenNext on Cloudflare Workers
The article discusses deploying a Next.js MDX blog to Cloudflare Workers using OpenNext. It highlights a common issue where the blog appears empty after deployment due to the way files are accessed. The author provides a solution by shifting file reading to build time instead of runtime, ensuring the blog functions correctly in the Cloudflare environment.
- ▪The blog worked locally but showed empty pages after deployment to Cloudflare Workers.
- ▪The issue arose because the blog code was designed for a Node.js app rather than the Cloudflare Workers environment.
- ▪The author recommends generating TypeScript files with post metadata during the build process to avoid runtime filesystem reads.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 1170773) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Harshal Ranjhani Posted on May 22 • Originally published at harshalranjhani.in Making Dynamic MDX Blogs Work with OpenNext on Cloudflare Workers #mdx #opennext #cloudflare #nextjs 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.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).