Passwordless send link from a backend

My problem is the following
1- I generate a passwordless link using the auth0 sdk authentication api and I use passwordless with connection email and sending a link
2- The link is sent successfully to the user’s email given to the sdk (there is no user interaction there, I also allowed this route to send the link from a different place from where he wants to login by the help of another forum topic)
3- When the user clicks on the link and is redirected to my website I get an error regarding the state not being present in the cookies or something

So I need help regarding that last step
here is a code snippet of sending the magic link:

export const sendMagicLink = async (
    hostname: string,
    email: string,
    redirect_uri: string
) => {
    const config = getAuth0Credentials(hostname)
    const sdk = new AuthenticationClient({
        domain: <domain>,
        clientSecret: config.clientSecret ?? '',
        clientId: config.clientID ?? '',
    })
    await sdk.passwordless.sendEmail({
        email,
        send: 'link',
        authParams: {
            state: <random string>,
            nonce: <random string>,
            response_type: 'token id_token',
        },
    })
}