Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic routing (directory param) doesn't work on the custom server #8092

Closed
mehmetnyarar opened this issue Jul 24, 2019 · 4 comments
Closed

Comments

@mehmetnyarar
Copy link

Bug report

Describe the bug

I have the following pages structure:

pages
  [role]
    signin.tsx
    dashboard.tsx
  index.tsx

This should work according to the blog article:

The [param] syntax is supported for directory names and file names, meaning the following examples work:
./pages/blog/[blogId]/comments/[commentId].js
./pages/posts/[pid]/index.js

The router seems to redirect correctly on the client side, however I get the following url for the server-side:

http://localhost:3000/[role]/signin?role=%5Brole%5D

I have a custom express server setup (to enable next-i18next):

server.get('*', (req, res) => {
    return handle(req, res)
  })

I also added a route handler just in case. The route is being caught by the handler but the outcome is same.

  server.get('/:role/signin', (req, res) => {
    return app.render(req, res, '/[role]/signin', { role: req.params.role })
  })

To Reproduce

I use the combination of the following examples:

plus TypeScript

Expected behavior

I expect the dynamic routing works properly.

Screenshots

(none)

System information

  • OS: MacBook Pro (Retina, 13-inch, Late 2013)
  • Browser Version 75.0.3770.142 (Official Build) (64-bit)
  • Version of Next.js: 9.02

Additional context

(none)

@Timer
Copy link
Member

Timer commented Jul 25, 2019

Without a full reproduction provided there's nothing we can do to help debug your setup.

@Timer Timer closed this as completed Jul 25, 2019
@adascal
Copy link

adascal commented Jul 25, 2019

@Timer I just created a simple example demonstrating the issue
Please checkout my branch: https://github.com/adascal/next-i18next/tree/dynamic-routing-issue-example

I just added a new page with dynamic routing post/[id].js

and if you run app, navigate in browser directly to http://localhost:3000/post/5 your url will be transformed into: http://localhost:3000/post/[id]?id=%5Bid%5D

So issue is pretty stable and easy to reproduce

All changes I've made are here: adascal/next-i18next@a6866a2

I used existing example from next-i18next, by added dynamic route

Maybe @isaachinman can look as well

@adascal
Copy link

adascal commented Jul 25, 2019

I've made a fix here: i18next/next-i18next#422

Hope to be merged soon

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants