301 Redirect inside RSC #54182
Unanswered
XEngine
asked this question in
App Router
Replies: 4 comments 1 reply
-
|
bumping. I really need to make 301. I can't seem the find a solution |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I'm also wondering why we can't do a 301. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@XEngine use permanentRedirect instead redirect |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've recently migrated my project to NextJS 13 AppDir and I'm encountering redirection issues. My category pages have dynamic URLs, and I need to validate whether a visitor types a brand name or a category name in the URL, such as "domain.com/adidas" or "domain.com/jeans". To achieve this, I'm checking the slug against my list of brands or categories to determine if the visitor is trying to access a brand page or a category page, in accordance with our company's URL structure policy.
However, for cases where an old category URL is accessed, I need to redirect it to a new one. Here's the code snippet I'm using for this purpose:
The issue I'm facing is that the redirection using redirect from "next/navigation" results in a 307 redirect status. I've been trying to find a way to indicate a 301 redirect status, but so far, I haven't been successful. Is there a way to achieve a 301 redirect status in this context?
P.S: I attempted to use middleware to address this issue. While it worked, I faced a challenge. The middleware doesn't cache the categories and brands retrieved from certain endpoints, making it impossible to revalidate whenever there are changes. Additionally, I explored using the FileSystem approach within middleware, but it only operates in the Edge runtime and isn't available in other contexts. Is there an alternative solution that would allow me to efficiently manage caching and achieve the desired redirection behavior maybe?
Beta Was this translation helpful? Give feedback.
All reactions