Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchRedirect not working on handleError with Polylang translated slugs #693

Open
1 task done
lucymtc opened this issue Feb 6, 2024 · 2 comments
Open
1 task done

Comments

@lucymtc
Copy link
Contributor

lucymtc commented Feb 6, 2024

Describe the bug

When having the Polylang integration enabled and slugs for post types are translated, the fetchRedirect pathname is not matching the translated slug in handleError, therefore a redirect added for a different locale in WP is not detected.

Steps to Reproduce

  1. Create custom post type., slug example 'programmes'
  2. Add translation to the post type slug in polylang, for example PT 'programas'
  3. Add rewrite in middleware so NextJS knows programas translated path is programmes/
  4. Add a redirect from from WP with Safe Redirect Manager from '/pt/programas/foo' that returns 404 to an existing page
  5. Within handleError function pathname is the ctx resolvedUrl which is programmes/foo
  6. See redirect not working.
  7. Inside handleError to test, hardcode pathname in fetchRedirect to '/pt/programas/foo' and see redirect working.

Screenshots, screen recording, code snippet

No response

Environment information

WP 6.4.3
Safe Redirect Manager 2.1.0
Polylang Pro 3.3.2
@headstartwp/core 1.1.2
@headstartwp/next 1.1.5

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lucymtc lucymtc changed the title fetchRedirect on handleError with polylang translated slugs not working fetchRedirect not working on handleError with Polylang translated slugs Feb 6, 2024
@nicholasio
Copy link
Member

I think we need better support for Polylang translated slugs featured. I'll look into how this could be better supported in general.

@nicholasio
Copy link
Member

nicholasio commented Mar 7, 2024

@lucymtc was your fix essentially skip using ctx.resovledUrl at all even when using getStaticProps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants