1

export async function POST(req:Request) {
  
  try {
    const body = await req.json()
    console.log(body);
    return new Response("ok")
  } catch (error) {
    console.log(error);
  }

}
when using postman to send a payload , the server console spits an 500 internal server error and this code will spit this :
SyntaxError: Unexpected number in JSON at position 1
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:6498:19)
    at successSteps (node:internal/deps/undici/undici:6472:27)
    at node:internal/deps/undici/undici:1145:60
    at node:internal/process/task_queues:140:7
    at AsyncResource.runInAsyncScope (node:async_hooks:204:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

EDIT : the endpoint i'm trying to reach is in app/api/testPost/route.tsx Postman ScreenShot : screenShotusing form-data tab

folder hierarchy

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Fadlo
  • 41
  • 5

1 Answers1

0

Comment out output: 'export' in next.config.js file and try again.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 12 '23 at 00:40