question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nest routing issue with nested pages

See original GitHub issue

Describe the bug It’s common to have page structures such as the following

- pages
  - index.tsx
  - users
    - index.tsx
    - [id].tsx

I have a simple UsersController that takes care of rendering all pages in pages/users. However, the following doesn’t work:

@Controller('users')
export class UsersRenderController {
  constructor(private usersService: UsersService) { }

  @Get('/')
  @Render('users/index')
  async showAll() {
    return {};
  }

The result is a 404.

Strangely, when renaming the file pages/users/index.tsx to e.g. pages/users/users.tsx and changing the @Render line appropriate, that does work! However, it would mess up rendering for Next.js.

This seems quite an obvious one, so what am I missing here? None of the examples contain nested pages, so it’s been hard to sanity-check.

Expected behavior It should be possible to render nested pages as in the example above, e.g. pages/users/index.tsx.

To Reproduce I can share the repo with someone privately, but it should be very simple to copy the above example in an existing repo.

Version

  • next.js: 12.3.1
  • nest: 9.0.0
  • nest-next: 10.0.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
yakovlev-alexeycommented, Nov 8, 2022

PR is updated. Also thrown in Vercel Next.js license just in case.

1reaction
yakovlev-alexeycommented, Nov 8, 2022

Logs definitely are not on purpose and are debugging leftovers - will remove them. Also thinking about renaming next directory to vendor/next. Probably will update the PR now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested routes do not keep prefix · Issue #21 - GitHub
I'm having a bit of trouble keeping my route definitions modular. In this repro repo I have the AppModule that says hello when...
Read more >
How to create nested routes with parameters using NestJS
So ideally I would create a parent route /accounts/:account/ which will contain the children routes ( resource1 , resource2 , resource3 , ...
Read more >
The Guide to Nested Routes with React Router - ui.dev
In this comprehensive, up-to-date guide, you'll learn everything you need to know about creating nested routes with React Router.
Read more >
Troubleshooting nested pages in Nuxt.js - LogRocket Blog
Nuxt.js implements nested pages in a very intuitive way. The pages directory in a Nuxt.js app contains the routes for that app.
Read more >
How to render nested route in new page? - Ember.JS
The issue isn't so much LinkTo or where the outlet is placed, it's more how your router map looks. If you want the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found