Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt)!: support universal global middleware #5038

Merged
merged 10 commits into from
Jun 27, 2022

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented May 18, 2022

πŸ”— Linked issue

resolves nuxt/nuxt#13888, closes #4795

❓ 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

This adds support for global middleware in the universal router - ie. even if the user doesn't have a pages/ directory. Note that only global middleware is supported so middleware must have a .global.ts suffix for it to be applied on route navigation. (This is for consistency.)

πŸ‘‰ Migration

  • If you are using pages:middleware:extend hook, then you can switch to using app:resolve, where you will be able to access app.middleware.

πŸ“ Checklist

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

@danielroe danielroe added enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels May 18, 2022
@danielroe danielroe requested a review from pi0 May 18, 2022 12:24
@danielroe danielroe self-assigned this May 18, 2022
@netlify
Copy link

netlify bot commented May 18, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit 48a6b96
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62ac4d7f46172c00089fe88d
😎 Deploy Preview https://deploy-preview-5038--nuxt3-docs.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@atinux
Copy link
Member

atinux commented May 18, 2022

Looks good to me ❀️ , would be nice to add a test for.

@danielroe danielroe changed the title feat(nuxt): support universal global middleware feat(nuxt)!: support universal global middleware May 19, 2022
@pi0
Copy link
Member

pi0 commented May 20, 2022

As discussed with @danielroe remaining changes:

  • Use an array format for middleware (supporting nameless middleware and consistency)
  • Add an alternative hook to extend route middleware. (postponed)

@danielroe
Copy link
Member Author

@pi0 Let me know when you plan to review this and I will resolve conflicts.

@pi0
Copy link
Member

pi0 commented Jun 17, 2022

@danielroe You can rebase. I think we are close to merge :)

@pi0 pi0 merged commit 8c2c80e into main Jun 27, 2022
@pi0 pi0 deleted the feat/universal-global-middleware branch June 27, 2022 12:10
@pi0 pi0 mentioned this pull request Jul 11, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support global middleware without pages
3 participants