Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new redirects feature (#2583)
## What's the purpose of this pull request? The implementation of the redirects feature in FastStore appears as a strategic solution to facilitate the migration of old stores to our platform. The idea of this feature is to run the redirect in the **getStaticProps** function when a certain page is not found. In other words, before rendering a **not found (404)** result to the user, we check if there is a redirect associated with the pathname requested by the user. Since the pathname is not found (404). The redirect flow follows two steps. First it goes through a customization function called **matcher**. If the matcher cannot resolve the redirects, we validate whether a redirect exists in the **rewriter** database. ![Captura de Tela 2024-12-10 às 10 18 24](https://github.com/user-attachments/assets/9f1a6fb0-da7d-46e3-80c0-69380f57eb40) ### Components - **Matcher**: Optional function that can be implemented via customization. Some pathnames can be resolved via simple logic, without necessarily going to a database to check if there is a redirect registered. [See an example](https://github.com/vtex-sites/starter.store/blob/fad4fde01c0151cf78e1f9de5a378e24afe3f28a/src/redirects/index.ts). - **Rewriter**: If the redirect is not resolved via customization, a call will be made to the rewriter api to check if there is a redirect associated with the requested pathname. [Redirects RFC](https://docs.google.com/document/d/15QxSNexAcDtrryDTR_LXcMmFLg2jnq2linMdp5-Q-r8/edit?usp=sharing) ## How to test it? https://storeframework.myvtex.com/admin/cms/redirects ![Captura de Tela 2024-12-12 às 10 08 49](https://github.com/user-attachments/assets/c3cb9e59-cc00-4d78-af87-dac91a690cb5) We can run locally and try to access one of these redirects. Example of matcher in starter: vtex-sites/starter.store#626 Example: `/produto/1` --------- Co-authored-by: eduardoformiga <eduardo.formiga@gmail.com>
- Loading branch information