Next.js Discord

Discord Forum

How to redirect to a proper sub-page?

Unanswered
Golden northern bumble bee posted this in #help-forum
Open in Discord
Golden northern bumble beeOP
How to redirect from /vendors/[id] to /vendors/[id]/general on getServerSideProp() or in the nextjs config?

I do like:
  return {
    redirect: {
      destination: `${id}/${VendorTabs.GENERAL}`,
      permanent: true,
    },
  }

but it ignores basePath.

UPD. /vendors here is the basePath

11 Replies

@joulev you just do `/vendors/${id}/general`?
Golden northern bumble beeOP
/vendors is the basePath
@Golden northern bumble bee `/vendors` is the basePath
hmm looks like a bug, could you submit a bug report
@joulev hmm looks like a bug, could you submit a bug report
Golden northern bumble beeOP
I don't think it's a bug, why would it be? You expect the path to be rewritten?
because destination should take basePath into account
Golden northern bumble beeOP
I see. Well I believe it's not in the docs, such a behavior. My question is how to get the basePath from inside getSSP
that one i don't know, but since basePath is a constant i suppose you can simply hardcode it?
maybe export a BASE_PATH from somewhere and import it to both here and next.config.js
Golden northern bumble beeOP
Yeah, well. Thanks
I thought there was a next way 😀
no, there isn't as far as i know