stytchauth / stytch-b2b-node-example

An example of Stytch's B2B authentication suite in a Next.js application
https://www.stytchb2bdemo.app/
MIT License
34 stars 6 forks source link

Example Doesn't work with Next.js 14 #43

Open grant opened 1 month ago

grant commented 1 month ago

Currently the sample is pinned to Next.js version "next": "13.1.6",

https://github.com/stytchauth/stytch-b2b-node-example/blob/0539e4c376dbde83a31e00d3ba6328392050987c/package.json#L32

If you try to upgrade this sample to use Next.js 14, Google OAuth sign-in fails:

{
"status_code": 400,
"request_id": "request-id-test-e8d908e1-9ff8-433d-aabb-a659a32948a3",
"error_type": "no_match_for_provided_oauth_url",
"error_message": "The sso redirect url in the request did not match any redirect URLs set for this project. Please visit https://stytch.com/dashboard/redirect-urls to update the redirect URLs for this project. For more information on why this validation is necessary please visit https://stytch.com/docs/api/url-validation",
"error_url": "https://stytch.com/docs/api/errors/400#no_match_for_provided_oauth_url"
}
nicole-stytch commented 1 month ago

Hey Grant! I just followed up here: https://forum.stytch.com/t/stytch-b2b-node-js-next-14/301

Please let us know if that doesn't resolve the issue!

grant commented 1 month ago

Thanks @nicole-stytch ! I'll look. FWIW, the sample works with Next 13 without this error.

Aside, can we please update the package dependencies though for this example? The package should use next 14, which is quite mature.

grant commented 1 month ago

For reference when looking back at this issue, here are the Next.js apps I see (all version 13):

https://github.com/stytchauth/stytch-b2b-nextjs-magic-links-example/blob/main/package.json https://github.com/stytchauth/stytch-nextjs-pages-router-example/blob/main/package.json https://github.com/stytchauth/stytch-nextjs-app-router-example/blob/main/package.json https://github.com/stytchauth/stytch-passkey-nextjs-example-app/blob/main/package.json

Next.js 15 comes out in October, so I'll try to upgrade Stytch with that version then.


I also noticed npm stytch is behind a major version ("stytch": "^10.5.0" not 11.2.0), so I'll try upgrading that at some point.