Next.js Discord

Discord Forum

`next dev` works fine yet `next build && next start` returns 404

Unanswered
Sealinator3000 posted this in #help-forum
Open in Discord
I have a fumadocs site that was working until a few days ago. Now it returns 404 on every page when next start but it works just fine on next dev.

I have the following next.config.mjs:

import { createMDX } from "fumadocs-mdx/next";

const withMDX = createMDX();

/** @type {import('next').NextConfig} */
const config = {
  serverExternalPackages: ["@takumi-rs/core", "typescript", "twoslash"],
  // output: "export",
  reactStrictMode: true,
  basePath: "/docs",
  // trailingSlash: true,
  images: {
    unoptimized: true,
  },
  async rewrites() {
    return {
      afterFiles: [
        {
          source: "/:path*.md",
          destination: "/llms.mdx/docs/:path*",
        },
      ],
    };
  },
};

export default withMDX(config);


And this souce.config.ts:

import { defineConfig, defineDocs } from "fumadocs-mdx/config";
import { metaSchema, pageSchema } from "fumadocs-core/source/schema";
import { remarkSteps } from "fumadocs-core/mdx-plugins/remark-steps";
import { remarkMdxMermaid } from 'fumadocs-core/mdx-plugins';
import { rehypeCodeDefaultOptions } from "fumadocs-core/mdx-plugins";

// You can customize Zod schemas for frontmatter and `meta.json` here
// see https://fumadocs.dev/docs/mdx/collections
export const docs = defineDocs({
  dir: "content",
  docs: {
    schema: pageSchema,
    postprocess: {
      includeProcessedMarkdown: true,
    },
  },
  meta: {
    schema: metaSchema,
  },
});

export default defineConfig({
  mdxOptions: {
    remarkPlugins: [remarkSteps, remarkMdxMermaid],
    rehypeCodeOptions: {
      themes: {
        light: "github-light",
        dark: "github-dark",
      },
      transformers: [
        ...(rehypeCodeDefaultOptions.transformers ?? []),
      ],

      // important: Shiki doesn't support lazy loading languages for codeblocks in Twoslash popups
      // make sure to define them first (e.g. the common ones)
      langs: ["js", "jsx", "ts", "tsx"],
    },
  },
});

5 Replies

When running bun run build Next.js displays all pages as built successfully
nyeki@ethereal ~/D/R/d/documentation (main)> bun run build
$ next build
▲ Next.js 16.3.4 (Turbopack)
✓ Running next.config.mjs took 41ms
[MDX] generated files in 8.883752999999956ms

  Creating an optimized production build ...
✓ Compiled successfully in 1629ms
✓ Finished TypeScript in 3.1s    
✓ Collecting page data using 9 workers in 1490ms    
✓ Generating static pages using 9 workers (29/29) in 1697ms
✓ Finalizing page optimization in 33ms    

Route (app)
┌ ○ /_not-found
├   /[[...slug]]
│ ├ ● /
│ ├ ● /quick-start
│ ├ ● /guides/tune-a-protection-profile
│ └ ● [+5 more paths]
├ ○ /api/search
├ ○ /llms-full.txt
├   /llms.mdx/docs/[[...slug]]
│ ├ ● /llms.mdx/docs/content.md
│ ├ ● /llms.mdx/docs/quick-start/content.md
│ ├ ● /llms.mdx/docs/guides/tune-a-protection-profile/content.md
│ └ ● [+5 more paths]
├ ○ /llms.txt
└   /og/docs/[...slug]
  ├ ● /og/docs/image.webp
  ├ ● /og/docs/quick-start/image.webp
  ├ ● /og/docs/guides/tune-a-protection-profile/image.webp
  └ ● [+5 more paths]


○  (Static)  prerendered as static content
●  (SSG)     prerendered as static HTML (uses generateStaticParams)
yet when I run bun start -p 4000 all pages return 404
all /, /docs, /docs/, /quick-start, /docs/quick-start, and so
bun dev and everything works fine