next.jsdigital-oceanjamstack

Page Not Found after Deploying Next.js Static Website on Digital Ocean App Platform


I've created a static website with Next.js that works fine locally (npm run dev) but after deploying as a static site to Digital Ocean App Platform I'm getting Page Not Found (404).

The routes are very simple - just / for the site. I have an index.tsx in the pages folder at the project root, and a _app.tsx for simple tailwind styles inclusion.

I'm not sure how to start debugging this.


Solution

  • Fixed! Just needed to manually specify

    output_dir: out
    

    for the static site in app.yaml on the Digital Ocean App Platform after configuring next.config.ts to:

    import type { NextConfig } from "next";
    
    const nextConfig: NextConfig = {
        output: 'export'
    };
    
    export default nextConfig;
    

    The output directive instructs Next to build a static site. See https://nextjs.org/docs/pages/building-your-application/deploying/static-exports.