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

feat: trpc next middleware #76

Merged
merged 12 commits into from
Jul 3, 2022
Merged

feat: trpc next middleware #76

merged 12 commits into from
Jul 3, 2022

Conversation

juliusmarminge
Copy link
Member

Closes #38

Sorry, I messed up the previous PR (#74).

@iDarkLightning
Copy link
Contributor

It's nicer to implement auth with the route metadata feature in my opinion since it enabled routes to easily opt in and out of requiring authentication

@juliusmarminge
Copy link
Member Author

juliusmarminge commented Jun 30, 2022

Good call. Made a poll on Discord to see which is more used.

Is this worse for performance though? With that approach (using meta) the middleware runs for every request and checking if it should authorize or not, where as with the current (non-meta) the middleware is only run for the endpoints after the middleware? (if it works like that???).

Kind of like Next's old middleware where you had to escape early depending on the url (the url in this case being the meta.hasAuth)?

@iDarkLightning
Copy link
Contributor

Yeah performance wise meta might be slightly worse considering that. As far as I am aware you are correct that the middleware will only run for endpoints inserted after the middleware (unless there's some technicalities I'm missing).

@nexxeln
Copy link
Member

nexxeln commented Jul 2, 2022

Is this ready to be merged now?

@juliusmarminge
Copy link
Member Author

Versioning and changelog left

@nexxeln
Copy link
Member

nexxeln commented Jul 2, 2022

Alright

@nexxeln
Copy link
Member

nexxeln commented Jul 3, 2022

Thanks!

@nexxeln nexxeln merged commit 5390e60 into t3-oss:main Jul 3, 2022
devvianto605 pushed a commit to devvianto605/create-devviantex-nextjs-app-deprecated that referenced this pull request Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scaffold NextAuth TRPC getSession middleware if both are selected.
3 participants