Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preflight request failures should not block navigation #34199

Closed
javivelasco opened this issue Feb 10, 2022 · 3 comments · Fixed by #35145
Closed

Preflight request failures should not block navigation #34199

javivelasco opened this issue Feb 10, 2022 · 3 comments · Fixed by #35145
Labels
Middleware Related to Next.js Middleware Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@javivelasco
Copy link
Member

When the Next.js application shows a Link to a route that holds a middleware in its routing path, we run what is called a "preflight" request. This is intended to know how the client should behave when navigating to that location. This points to the bundle that should be preload, the redirection target if any, etc.

Currently, when this request fails, the client is no longer able to navigate and clicking the Link would just not work. In such cases, the client should control the error and instead perform a hard navigation to the link once it is clicked.

@nkzawa
Copy link
Contributor

nkzawa commented Mar 7, 2022

Does this just mean to ignore the error completely, or give a way to control what to do by like a flag or a callback?

@ijjk
Copy link
Member

ijjk commented Mar 7, 2022

@nkzawa we shouldn't ignore the error per se, we should treat this us being unable to navigate client-side similar to when we fail to load a JS bundle or _next/data route and do a hard navigation window.location.href = as instead

@kodiakhq kodiakhq bot closed this as completed in #35145 Mar 8, 2022
kodiakhq bot pushed a commit that referenced this issue Mar 8, 2022
fixes #34199

Also fixes response code to return `500` when showing error page of preflight request failure on dev mode

## Bug

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

github-actions bot commented Apr 8, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Middleware Related to Next.js Middleware Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants