Antoine
Antoine

Reputation: 560

Next.js catch all routes from index with only one getServerSideProps

I'm new to React and Next.js, but after following the doc of dynamic routes I've successfully created a subpage catching all routes, and beeing able to get that on the server side. see the image:

subpage catching all routes

My problem is that I'd like to have this behaviour from my index.tsx page, to be able to catch everthing on the home page and get the full url. What I've done is rename my index.tsx to [...].tsx and it redirects well to the home page no matter the route. The issue by doing that is my function getServerSideProps is called twice and I've no ideas why.

How should I do to be able to catch every routes from my homepage and get the complete url ?

Thank you !

Upvotes: 2

Views: 2476

Answers (1)

Antoine
Antoine

Reputation: 560

I've found that there is nothing wrong with the code, my issue was a chrome extension. I've now a page page/[...alias].tsx catching all routes with no problems :).

Upvotes: 1

Related Questions