Help running Fumadocs on cloudflare pages
Unanswered
Cuban Crocodile posted this in #help-forum
Cuban CrocodileOP
Hi! I am trying to run fumadocs on cloudflare pages but i can't seem to get it done because of node:path
Is there any other way ? I have setup cloudlfare pages with the build command and nodejs_compat flag
10:57:31.261 ▲ Import trace for requested module:
10:57:31.261 ▲ node:path
10:57:31.261 ▲ ./node_modules/.pnpm/fumadocs-mdx@9.0.2_fumadocs-core@13.2.2_next@14.2.5/node_modules/fumadocs-mdx/dist/index.mjs
10:57:31.261 ▲ ./app/source.ts
10:57:31.261 ▲ ./app/api/search/route.ts
10:57:31.262 ▲ ./node_modules/.pnpm/next@14.2.5_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Fsearch%2Froute&page=%2Fapi%2Fsearch%2Froute&pagePath=private-next-app-dir%2Fapi%2Fsearch%2Froute.ts&appDir=%2Fopt%2Fbuildhome%2Frepo%2Fapp&appPaths=%2Fapi%2Fsearch%2Froute&pageExtensions=mdx&pageExtensions=md&pageExtensions=jsx&pageExtensions=js&pageExtensions=tsx&pageExtensions=ts&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!./app/api/search/route.ts?__next_edge_ssr_entry__
10:57:31.262 ▲
10:57:31.262 ▲ ./node_modules/.pnpm/fumadocs-core@13.2.2_@types+react@18.3.3_next@14.2.5_react-dom@18.3.1_react@18.3.1/node_modules/fumadocs-core/dist/source/index.js:9:1
10:57:31.262 ▲ Module not found: Can't resolve 'path'
10:57:31.262 ▲
10:57:31.262 ▲ https://nextjs.org/docs/messages/module-not-found
10:57:31.262 ▲
10:57:31.262 ▲ Import trace for requested module:
10:57:31.262 ▲ ./app/source.ts
10:57:31.262 ▲ ./app/api/search/route.tsIs there any other way ? I have setup cloudlfare pages with the build command and nodejs_compat flag
25 Replies
Hmm have you installed the
@types/node package? Also we highly recommend to use static export for hosting Fumadocs sites outside of VercelYou can't run fumadocs on edge runtime
you don't have access to filesystem
@Cuban Crocodile
fumadocs can be static, so it works very well in cloudflare pages
just ensure the relevant stuff are made static. for example i think OP's
/api/search/route.ts is currently dynamically rendered. remove the export const runtime = "edge" statement thereI only know svelte so still wrapping my mind around next js and react
Will try the above solutions
@fuma Hmm have you installed the `@types/node` package? Also we *highly* recommend to use static export for hosting Fumadocs sites outside of Vercel
Cuban CrocodileOP
Not working..
### what i did
- pnpm create fumadocs-app
- cd folder_name
- pnpm run dev
- it installed @types/node automatically
- exit and then edit the next.config.mjs with these options
- deploy to cloudflare
@joulev i only added it afterwards when i saw runtime error, but anyways i removed and still no success. But the error is different this time
### what i did
- pnpm create fumadocs-app
- cd folder_name
- pnpm run dev
- it installed @types/node automatically
- exit and then edit the next.config.mjs with these options
import createMDX from 'fumadocs-mdx/config';
const withMDX = createMDX();
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
output: 'export',
compress: true,
swcMinify: true,
cleanDistDir: true,
};
export default withMDX(config);- deploy to cloudflare
i think OP's /api/search/route.ts is currently dynamically rendered. remove the export const runtime = "edge" statement there
@joulev i only added it afterwards when i saw runtime error, but anyways i removed and still no success. But the error is different this time
15:39:57.089 Error occurred prerendering page "/api/search". Read more: https://nextjs.org/docs/messages/prerender-error
15:39:57.090
15:39:57.090 Error: Route /api/search with `dynamic = "error"` couldn't be rendered statically because it used `nextUrl.searchParams`.
15:39:57.091 at Object.get (/opt/buildhome/repo/node_modules/.pnpm/next@14.2.5_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:39665)
15:39:57.091 at GET (/opt/buildhome/repo/.next/server/app/api/search/route.js:1:725)
15:39:57.091 at /opt/buildhome/repo/node_modules/.pnpm/next@14.2.5_react-dom@18.3.1_react@18.3.1/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:36264think it can't pre-render because the search params are not known
Similar stuff in svelte when using statis adapter
Similar stuff in svelte when using statis adapter
hmmm you're using static export?
Cuban CrocodileOP
i am
output: 'export',if you want to use Search API, it cannot be static exported
Cuban CrocodileOP
🤦♂️ oof
unless you use Algolia Search or move it to a 3rd party server
Cuban CrocodileOP
in the meanwhile i came up with a solution
i push to github -> build docker image -> use that on my server
connect watchtower, and it will auto restart on update
connect watchtower, and it will auto restart on update
yet to try last part, but should work
Great project btw!
@fuma unless you use Algolia Search or move it to a 3rd party server
Cuban CrocodileOP
Just a suggestion but maybe something like lunr can be added, which mkdocs uses
https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-search/?h=search
https://squidfunk.github.io/mkdocs-material/setup/setting-up-site-search/?h=search