0

I'm running into a problem trying to get routes working with [params]/:params.

The paths I'm working with will always be structured as follows: console/sites/[siteId]/possibly-another-directory/page.

The console/sites portion I can set as basePath in next.config.js but the [siteId] is something I would rather not have to manually add to every path in order to not end up with console/sites/possibly-another-directory/page. Is there a single place I can set this so that it will be included in every path I link to from within my site?

FWIW, I've tried setting my basePath to /console/sites/:siteId but :siteId was being read as a literal value.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
flyingace
  • 1,707
  • 17
  • 24
  • You can't have dynamic values as `basePath`, if that's what you're asking. Do you even need to do that though? Couldn't you structure your `pages` folder in a way that would suit those requirements? – juliomalves Oct 14 '21 at 16:53
  • @juliomalves I was saying that I *had* tried adding a dynamic value into my `basePath` but that didn't work, as you've noted. What I'm trying to find is a way to avoid having to include a reference to the `siteId` in every Link's href since it will remain fairly constant once the site loads, just as the `basePath` is going to be constant. I would like to avoid a situation where a Link is added to the site but the dev forgets to insure that the path begins with `pathId` as it will need to (i.e., `\`/${pathId}/directory/page\``). So far I haven't found a solution to this problem though. – flyingace Oct 17 '21 at 19:58

0 Answers0