We want to programmatically send magic links to users to invite them into our application. We will write server-side logic to start the passwordless process, which will be set with the client ID for our client application. So far, I have tested this, and when I click the link and get redirected back to my client application (Next.js for context), I encounter a callback handler error stating: “MissingStateCookieError: Missing state cookie from login request (check login URL, callback URL, and cookie config).”
After investigating, it seems that passwordless authentication typically has to be initiated from the universal login page, where the state gets set to avoid this issue. However, since we want to do this programmatically from the server-side when inviting members to log in, it appears the state is not being properly set because there is no way for them to communicate at this point.
Do you have any recommendations for aligning the state if the authentication flow starts on the server but ends on the client? Alternatively, if there is a better approach, please let me know. Also, is this even a recommended approach for inviting users to join your platform just by email? We want to make it as simple as possible.