Reputation: 93
I have been banging my head on this specific set-up. I am trying to achieve a set-up with Next.js where I can rewrite different sets of category pages to a catch-all route. But it always leads to a 404. Does someone know why?
next.config.js
{
rewrites: async () => {
return [{
source: "/actual-route/:slug*",
destination: "/collection/:slug*",
},{
source: "/another-route/:slug*",
destination: "/collection/:slug*",
}]
}
}
collection/[...slug].tsx
export async getStaticPaths() {
return {
paths: [
{
params: {
slug: ["actual-route"],
},
},
{
params: {
slug: ["actual-route", "child"],
},
},
{
params: {
slug: ["another-route"],
},
},
{
params: {
slug: ["another-route", "another-child"],
},
},
],
fallback: "blocking",
};
}
export async getStaticProps({ params }) {
return { props: {slug: params.slug}} // It doesn't get to here
}
Upvotes: 1
Views: 154