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.

Redirects not working from NextJS getServerSideProps

See original GitHub issue

I followed the way the documentation describes how redirects from drupal can be received from translatePathFromContext. Unfortunatelly the redirects are always empty, even when there are redirects in drupal from same path i am visiting…

is there some setting i miss, maybe persmissions or something else?

this is the code

  const path = await drupalClient.translatePathFromContext(context, {
    withAuth: true
  });

  console.log(path?.redirect);

The log is always “undefined”.

Does it makes a difference if “getServerSideProps” or “getStaticProps” is used for next-drupal? Is there a difference in the context object?

I was also wondering, in some cases the original path “/node/3” is working, in other cases only path-aliases are working, without any original paths. And when they are working, also no redirect is happening to the path-alias, only display of content.

Maybe any insight knowledge would be helpful, to figure out what is going on with redirects and if there also special permissions needed.

My Next-JS Consumer also have no admin-rights, because giving him admin-rights would mean we would need no seperate role for the nextjs user, so i try to omit that. Could this be the source of the problem? but then, which permission is missed from here?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
shadcncommented, Nov 1, 2022

@devtim123 Let me see if I can reproduce this. I’ll get back to you.

0reactions
martdavidsoncommented, Nov 17, 2022

EDIT: I’m deleting this whole comment.

My issue currently is with the decoupled router module, not with this package. When the decoupled router correctly resolves a redirect, next-drupal is redirecting correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Next.js getServerSideProps redirection ...
++ I tried to make redirection code in Client-Side, but it shows private page for a second and redirected. I want to block...
Read more >
Return redirect from getServerSideProps #11281 - GitHub
In our case we can ignore the client side routing part, because we need the redirects just for SEO which does no client...
Read more >
next.config.js: Redirects
Redirects allow you to redirect an incoming request path to a different destination path. To use Redirects you can use the redirects key...
Read more >
How to implement redirects in Next.js - LogRocket Blog
Redirects enable users to transfer an executed URL to a new URL to reroute an incoming request from one path to another.
Read more >
Refreshing Server-Side Props - Next.js - Josh W Comeau
Here's my problem: in my dashboard, I'm able to edit users, to bestow purchases or update their name: Notice how the updated name...
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