rsnext/test/integration/middleware
Javi Velasco 2e5218c778
Fix hydration middleware effects (#31800)
Whenever we trigger a route change in the client we check if there route we are navigating to is affected by a middleware. When this is the case we run a preflight and in case there is an effect that tells us that the middleware is responding with content we force a _refresh_. This is fine for navigation in general but it is not ok when the change is triggered for hydration. For example, in cases where the rendered page is a dynamic page this triggers an infinite reload.

In this PR we add a test where we add a `_middleware` that proxies to a dynamic path. When making a request to `/interface/root-subrequest` there will be a middleware that simply performs a fetch against localhost for the same `/interface/root-subrequest`. The new request will skip the middleware to avoid loops and then render the dynamic page. Then client will force a change for hydration resulting in a preflight request that tells that the client must refresh because for that path there is a middleware writing content.

Then we add a fix which simply consist of checking the internal option that tells when a change is triggered for hydration and skip the preflight in such scenario.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-11-26 12:46:57 +00:00
..
core Fix hydration middleware effects (#31800) 2021-11-26 12:46:57 +00:00
hmr Fix HMR for middleware #30791 (#31548) 2021-11-18 18:23:52 +00:00
with-base-path fix(31013): add base path to preflight request url (#31101) 2021-11-09 19:03:05 +00:00
with-eval run middleware parser handler only for middleware modules (#31219) 2021-11-10 15:31:46 +00:00
with-i18n Fix middleware i18n rewrites (#31174) 2021-11-09 01:28:39 +00:00