Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@danielroe
Copy link
Member

@danielroe danielroe commented Jan 23, 2023

πŸ”— Linked issue

resolves #15407, resolves #15738

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

When we redirect within middleware, we need to tell vue router not to finish the route navigation or the page will load after all (on server side). This wasn't affecting the response but it was allowing forbidden routes to be hit on server side, and causing some unexplained errors in server logs.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Jan 23, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@danielroe danielroe changed the title fix(nuxt): let vue router handle internal redirects within middleware fix(nuxt): let router handle internal redirects within middleware Jan 23, 2023
@danielroe danielroe merged commit de4086f into main Jan 23, 2023
@danielroe danielroe deleted the fix/mw-redirections branch January 23, 2023 11:18
@danielroe danielroe mentioned this pull request Jan 24, 2023
@ydnar
Copy link

ydnar commented Jan 26, 2023

This change seems to break route middleware that strips trailing slashes, e.g. /about/ β†’ /about, which match the same destination route. SSR emits status code 301 (or 302), but responds with content and no Location header.

@TheAlexLichter
Copy link
Member

This change seems to break route middleware that strips trailing slashes, e.g. /about/ β†’ /about, which match the same destination route. SSR emits status code 301 (or 302), but responds with content and no Location header.

Please create a new issue with reproduction then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client Component setup runs before router middleware is resolved

5 participants