Next.js 14 ignoring my API route completely even though route.ts exists and is named correctly

1 hour ago 1
ARTICLE AD BOX

I'm facing a strange issue in a Next.js 14 (App Router) project.
My API route exists, is named correctly, and the folder structure follows the official Next.js documentation, but the route is still completely ignored.


🔹 The API route never registers

When I call:

POST http://localhost:3000/api/generate-product-image

Next.js returns:

404 Not Found

The same happens even when I directly open the route in the browser:

http://localhost:3000/api/generate-product-image

There is no server log, no error, nothing — as if the file doesn't exist.


🔹 Folder Structure (confirmed correct)

app/ api/ generate-product-image/ route.ts creative-tools/ product-images/ page.tsx

(I have double-checked spelling, casing, dashes, and folder names.)

I even deleted node_modules, .next, and restarted the dev server multiple times.


🔹 route.ts

import { NextResponse } from "next/server"; export async function POST(req: Request) { return NextResponse.json({ message: "API working" }); }

🔹 What I have already tried

Restarted dev server (CTRL+C → npm run dev)

Deleted .next folder

Deleted and reinstalled node_modules

Verified the folder structure is EXACT (no typos)

Verified file name is exactly route.ts

Verified I’m using App Router, not Pages Router

Tried GET and POST methods

Ensured no middleware is blocking it

Tried accessing the route directly in browser

Moved the API folder to root /app/api/...

Created a test API route in the same folder → still not detected

Checked if any parent folder has a page.tsx (it doesn’t)

Still, Next.js acts like the API route is not there at all.


🔹 Additional Info

Next.js version 14.x

Project uses App Router

Running on localhost:3000

No TypeScript errors

Other parts of the app work normally

I previously asked a question (link below), followed the suggestion, and the error disappeared — but the API route still does not register.

(You can optionally insert the link to your old SO question here)


Question

What can cause Next.js App Router to completely ignore an API route even when:

The file exists

The folder structure is correct

The file name is correct

The dev server is restarted

No build errors appear

Are there any edge cases that prevent API route registration?

Read Entire Article