NextJS 15 Basic API Route Always Returning 404
Answered
Billy posted this in #help-forum
BillyOP
Anyone else having issues getting a really basic API request working in NextJS 15? I have a request
and when I make a request it returns a 404. I know in theory the force-dynamic isn't needed anymore as they fixed it but it made no difference without it
/api/revalidate
with import { revalidateTag } from 'next/cache'
import { NextResponse } from 'next/server'
export const dynamic = 'force-dynamic'
export async function GET(): Promise<any> {
// revalidateTag('services.update')
return NextResponse.json({ hello: 'hi' })
}
and when I make a request it returns a 404. I know in theory the force-dynamic isn't needed anymore as they fixed it but it made no difference without it
50 Replies
BillyOP
@Jboncz 🙂
What nextjs version you running?
BillyOP
latest stable
so 15. okay I havent done anything with it yet. give me one sec.
BillyOP
👍
ill bootstrap a new proj rq
What does the path to that route.js file look like?
This works no issues.
BillyOP
/src/app/api/revalidate/route.ts
in your browser your hitting localhost:3000/api/revalidate yeah?
BillyOP
browser and Postman
Hrmmm.
I have zero issues.
with TS
import { NextResponse } from "next/server";
export async function GET(request: Request) {
return NextResponse.json({hello: 'hi'})
}
Can you try replacing your code with this and see if it works
BillyOP
can you confirm that you can get to localhost:3000?
just the base route?
BillyOP
Everything else works
are you in build or dev?
BillyOP
dev
Iv tried turbo and non turo
turbo*
BillyOP
BillyOP
The errors is just the formatting and missing types, as I directly copied and pasted your code.
Sorry for asking basic questions... just never know.
BillyOP
wait a fkn sec
BillyOP
nvm
look at your route..ts file
Answer
BillyOP
remove a period and I think thatll do it for ya
BillyOP
its 6AM and iv been up since 8AM yesterday
how tf didn't I see that
Hahah, all good man.
BillyOP
I feel stupid
Thats why I was asking for screenshots it happens.
No worries!
BillyOP
Well thanks for the help.
❤️
np. please mark an answer using the replied to chat.
Just so it closes and indexs and all that jazz
GL!
and ty for closing