2

When I navigate to http://localhost:3000/users/123?foo=bar of my nextjs app I get the following when I print out router.query

{id: "123"}

What could be the reasons it is not adding foo: 'bar' to the query object?

grabury
  • 4,797
  • 14
  • 67
  • 125

2 Answers2

-1

Your file layout should look like this:

pages/
  users/
   [id].js

Having just tested this, the returned query object is {"foo":"bar","id":"123"}.

ven
  • 196
  • 1
  • 3
-1

I had to add a next.config.js file with the following

module.exports = {
  reactStrictMode: true,
  async rewrites() {
    return [
      {
        source: '/pages/:slug*',
        destination: '/:slug*'
      }
    ]
  }
}
grabury
  • 4,797
  • 14
  • 67
  • 125