Next.js Discord

Discord Forum

What method in next.js should I use to implement the api interface from the backend HTTPS?

Unanswered
Baldfaced hornet posted this in #help-forum
Open in Discord
Baldfaced hornetOP
Hi guys, I have a https api interface from the backend, what is the best way I should use in next.js to implement it? Currently my file directory structure is /app/products/pages.tsx
/app/api/products/route.ts but the request always fails to pass data to the backend

2 Replies

but the request always fails
Please clarify
Bosnian Coarse-haired Hound
I'm also facing same issue

my nextjs app is running on localhost
project structure:
── 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
│ │

--------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