-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#38] [Backend] As a user I can login with an OAuth provider #79
[#38] [Backend] As a user I can login with an OAuth provider #79
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While re-using existing code is a good idea, I am unsure if we should still keep using next-connect
with Next.JS 13.
I used that package as 1) passport is THE battle-tested oAuth library in the Node community, and 2) API routes in Next.JS 12 (with the Pages router) were quite "poor" (we had to check on the HTTP verb, e.g., `if req == 'POST').
However, Next.JS 13 (with the App router) has better server-side components, including routes handlers. So we can do defining GET and POST endpoints with function GET() {}
and function POST() {}
. So I believe we can do more backend logic similarly to what we do with Express (see this article to do oAuth without even passport).
I am not against using https://next-auth.js.org/ if it is easier (e.g, easier to test) and better (e.g., more secure, bug-free). I want to make sure we understand our options.
nextjs-13/package.json
Outdated
"next": "13.4.3", | ||
"next-connect": "0.13.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package is now outdated as there is a newer 1.0.0 version that has been in the works and released: https://github.com/hoangvvo/next-connect/releases/tag/v1.0.0
Yes I see. I just updated the PR description. What do you think about this? And there's also this one thing. When using passport authenticate, we are using it as And seems like it's indeed the The Nextjs and it's ecosystem are still new to me so I appreciate your help a lot :D. |
Hi @olivierobert, I decided to go with the |
88ecdf6
to
1759569
Compare
1759569
to
2884dbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall 👍 Just two minor issues to fix before it can be merged.
}); | ||
|
||
describe('given there is NO matching user', () => { | ||
it('return null', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typo issue:
it('return null', async () => { | |
it('returns null', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just fixed it!
…om:nimblehq/js-framework-benchmark into feature/38-nextjs-v13-backend-google-oauth
[#38] [Backend] As a user I can login with an OAuth provider (#79) [#56] Create GitHub action CI workflow (#80) [#54] Create GitHub Action CI workflow (#88) setup unit testing with simple Test and setup GH action fix testing setup and fix CI fix CI fix CI 2 fix CI 3 setup Remix auth for login by gmail, create url login and 403 Fix new request add link break to the third-party
Close #38
What happened 👀
Insight 📝
Reuse old structure Next.js code
This PR mostly reuse the code from PR #2 for convenience.
NextAuth
When compare NextAuth to Passport, we can easily see that Passport is more battle-tested, support more oAuth providers, more popular(21.5k stars on Github, compared to 16.7k of NextAuth), but I see NextAuth is more suitable for our POC, since:
Route Handler
Passport
andRoute Handler
andnext-connect
are not compatible yet. And it's also because theRoute Handler
of Next.js 13 can already replace some parts of thenext-connect
now.route.js
file,Proof Of Work 📹
CleanShot.2023-05-23.at.15.18.13-converted.mp4