Next.js Discord

Discord Forum

404 HTML page for API response

Answered
Round sardinella posted this in #help-forum
Open in Discord
Round sardinellaOP
Hey there,
I'm trying to POST my http://localhost:3000/newroute with postman but I get the 404 not found HTML page in response
app/api/newroute
import type { NextApiRequest, NextApiResponse } from "next";

type ResponseData = {
  message: string;
};

export default function handler(
  req: NextApiRequest,
  res: NextApiResponse<ResponseData>
) {
  res.status(200).json({ message: "Hello from Next.js!" });
}
Answered by B33fb0n3
you can't access your localhost from outside of your network. You can publish your page for a specific time using ngrok for example. With this you can also easily get an https://... then you can access from outside this url with the specific api
View full answer

4 Replies

you can't access your localhost from outside of your network. You can publish your page for a specific time using ngrok for example. With this you can also easily get an https://... then you can access from outside this url with the specific api
Answer
great to hear I could help 🙂
please mark solution