Facing API Route issue in my nextjs app which is running on localhost project structure: next@14.2.
Unanswered
Bosnian Coarse-haired Hound posted this in #help-forum
Bosnian Coarse-haired HoundOP
── src/
│ ├── app/
│ │ ├── bookings/
│ │ │ ├── flights/
│ │ │ ├── hotels/
│ │ │ ├── cabs/
│ │ │ └── buses/
│ │ ├── chatbot/
│ │ ├── travel-planner/
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ ├── about/
│ │ └── api/
│ │ ├── users/
│ │ │ ├── route.ts
│ │ ├── bookings/
│ │ │ ├── route.ts
│ │ ├── flights/
│ │ │ ├── route.ts
// app/api/users/routes.ts
import { NextResponse } from "next/server";
export function GET(){
console.log('Signup route working');
return NextResponse.json({ message: 'Signup route working' });
};
http://localhost:3000/api/users
Getting 404 Not found
│ ├── app/
│ │ ├── bookings/
│ │ │ ├── flights/
│ │ │ ├── hotels/
│ │ │ ├── cabs/
│ │ │ └── buses/
│ │ ├── chatbot/
│ │ ├── travel-planner/
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ ├── about/
│ │ └── api/
│ │ ├── users/
│ │ │ ├── route.ts
│ │ ├── bookings/
│ │ │ ├── route.ts
│ │ ├── flights/
│ │ │ ├── route.ts
// app/api/users/routes.ts
import { NextResponse } from "next/server";
export function GET(){
console.log('Signup route working');
return NextResponse.json({ message: 'Signup route working' });
};
http://localhost:3000/api/users
Getting 404 Not found
4 Replies
Spectacled bear
Hey i'm facing the same issue, i have an api end point i my src folder. Did you find a solution for your issue?
api needs to be inside app folder
It's route.ts and make sure your handler is async @Bosnian Coarse-haired Hound
@Bosnian Coarse-haired Hound ── src/
│ ├── app/
│ │ ├── bookings/
│ │ │ ├── flights/
│ │ │ ├── hotels/
│ │ │ ├── cabs/
│ │ │ └── buses/
│ │ ├── chatbot/
│ │ ├── travel-planner/
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ ├── about/
│ │ └── api/
│ │ ├── users/
│ │ │ ├── route.ts
│ │ ├── bookings/
│ │ │ ├── route.ts
│ │ ├── flights/
│ │ │ ├── route.ts
// app/api/users/routes.ts
import { NextResponse } from "next/server";
export function GET(){
console.log('Signup route working');
return NextResponse.json({ message: 'Signup route working' });
};
http://localhost:3000/api/users
Getting 404 Not found
do you have another
app folder or pages folder outside src by any chances?