You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Give content editors the ability to add individual redirects
Give CMS the ability to programmatically generate and store redirects
Have real time up-to-date 308 redirects
Non-Goals
No response
Background
One of the nice things about our current monolithic website solution (that we're trying to move away from), is the ability for content editors to add redirects in real time. There is currently no way to completely match this with NextJS. Redirects in the Next config file are only generated at build time, middleware is incapable of caching fetch data and does not catch client side requests that should be redirected, and adding it as a fallback in a dynamic catch-all page.tsx only uses meta redirects, not 307/308.
Proposal
Add the option for a redirects.ts file in the root/src directory. This file would be able to cache fetch requests same as a page.tsx file, with the ability to set a revalidate time and cache tags. The fetch would stay cached until the revalidate time was up, or revalidateTag was called with a relevant tag. It would export an array of redirect objects. The server should behave exactly as it does currently with redirects set in the Next config.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
One of the nice things about our current monolithic website solution (that we're trying to move away from), is the ability for content editors to add redirects in real time. There is currently no way to completely match this with NextJS. Redirects in the Next config file are only generated at build time, middleware is incapable of caching fetch data and does not catch client side requests that should be redirected, and adding it as a fallback in a dynamic catch-all page.tsx only uses meta redirects, not 307/308.
Proposal
Add the option for a
redirects.ts
file in the root/src directory. This file would be able to cache fetch requests same as a page.tsx file, with the ability to set a revalidate time and cache tags. The fetch would stay cached until the revalidate time was up, or revalidateTag was called with a relevant tag. It would export an array of redirect objects. The server should behave exactly as it does currently with redirects set in the Next config.Example redirects.ts:
Beta Was this translation helpful? Give feedback.
All reactions