Next.js API routes do not work when Go function is present

API routes generated from Next.js generate a permanent, default 404 page when coupled with an additional, custom Go function.

The Go function is working correctly, but the API routes generated by Next.js are returning a permanent 404 page. The Go function is placed in the top-level /api/<go-function>.go , while the API route is located in src/app/api/<route-name>/route.ts.

file structure

  • api
    • server-lookup.go
  • src
    • app/api/check-upvote
      • [slug]
        • route.ts

expected behavior
Both Next.js dynamic route and Go function are accessible through /api routes

current behavior
When /api/server-lookup.go is present, it works fine, but the Next.js api routes all return default 404 pages

When Go function is inside of /functions/server-lookup.go and it is defined correctly in the vercel.json file, Vercel build process as well as vercel dev return The pattern "src/functions/*.go" defined in "functions" doesn't match any Serverless Functions

When Go function is not present, Next.js api routes work fine

Next.js 15.2.3

There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.

A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0.