Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sfs 1755 generate middleware in build time (#2540)
## What's the purpose of this pull request? This task will allow enabling the redirects middleware within **@faststore/core** during the build process based on a flag. The idea is to enable this functionality only for projects that have the flag `ENABLE_REDIRECTS_MIDDLEWARE` saved in the env vars and which are hosted by homebrew. In the future, we intend to have control of this feature through webops. Next steps: - Set this flag in a pipeline env var. - Implements dynamoDB client (Reference: #2517) ## How it works? The key is the name of the file: **middleware__DISABLED.ts** This middleware is disabled by default. Only stores that are in **homebrew** and want this functionality will be able to enable it via a feature flag. When the flag is active, the CLI at build time will check whether the **ENABLE_REDIRECTS_MIDDLEWARE** flag is set or not, if so, the file name will be changed to **middleware.ts** and nextjs will know how to automatically deal with it. ## How to test it? I created a [PR](vtex-sites/starter.store#599) with the flag enabled, clone the branch and then: - Run `yarn build` - check if the **middleware.ts** was created inside **.faststore/src** ### References https://docs.google.com/document/d/1iC1fLwJbypnvDyp_JilKBfQfaHjFDHYrjS1kC722sB4/edit?tab=t.0#heading=h.tglo77yl0lf5
- Loading branch information