reproduction case for CORS issue with server functions#24
reproduction case for CORS issue with server functions#24joeholdcroft wants to merge 4 commits intoworkos:mainfrom
Conversation
|
Thanks for this, I was able to reproduce and know what the problem is. In a nutshell, the client expects a server action but is given a redirect instead as authkit-nextjs detects that the user is logged out and tries to redirect to AuthKit. Browser says no because of CORS and you get this error. We're going to have a think on what the best practise is here, I'm initially thinking we return an error instead of trying to hijack the request and letting the client handle a redirect. |
|
@PaulAsjes indeed! Thanks for taking a look. Your approach seems reasonable. Another other idea I had was to create an interstitial page that you can redirect to instead on the same app, which in turn redirects to the login page. |
|
So after a bunch of back-and-forth we've settled on what I think is the "best" (albeit not great) solution: workos/authkit-nextjs#68 Keen to hear your thoughts! |
|
Hey @PaulAsjes - thanks for getting back to me! I don't love it, mainly because the suggestion is that we make an assumption that an error of any type in a server action is due to the user being logged out, and we redirect them to the login screen. In reality, there are many reasons we might get an error from a server action, and only for this specific case would redirecting to the login screen make sense. Or am I missing something, is there some way to detect that the error is due to the user being logged out? Did you consider my approach too?
|
|
Hey @joeholdcroft, we agreed with your assessment and came up with a solution that we think works much better. By wrapping the app code in an Have a look at the updated README for instructions: https://github.com/workos/authkit-nextjs |
|
@PaulAsjes that's great news, thank you! I just tried bumping the SDK version and simply wrapping our app in the
|

Steps to reproduce
npm i,npm run dev/auth/callback)