0

I'm using NextJS and custom server with Express, But I got a problem when defining my routes in Express.

When I define Express routes like below it will throw an errors

app.get('/:username', handle.profile)
app.get('/:username/:id', (req, res) => {
  res.send('id')
})

But the errors just appears when I'm in Development mode. Which is when I go with Production the errors not shown.

Though errors in console, but all run normally, I just can't figure out why the error message coming. It's a weird.

Here's the errors message

Error with on-demand-entries-ping: Unexpected token i in JSON at position 0

Here's screenshot of the errors Express routes error

But when I define Express routes like below

app.get('/:username', handle.profile)
app.get('/:username/forum/:id', (req, res) => {
  res.send('id')
})

In Production or Development mode the errors is go on, my application going well.

Any solution please?

2 Answers 2

0

I know this is an older issue, but if you're still experiencing this error double-check your npm scripts in package.json. Since you're using a custom server, the standard "dev": "next" script won't work. You'll need something along the lines of "dev": "node server.js" to run the app via your Express instance.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, it's NextJS bugs It's already patched by NextJS Developer (Arunoda) :)
0

It's Next.JS bugs and already fixed by https://github.com/zeit/next.js/pull/1658

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.