Authentication in react returning null token

I have the following react code for authenticating a session:

useEffect(() => {
if (session.session) {
navigate(‘/’)
} else {
const token = new URLSearchParams(window.location.search).get(‘token’);
console.log(token);
client.magicLinks.authenticate(token, {
session_duration_minutes: 10080
}).then(() => {
navigate(‘/’)
})
}
}, [client, session, navigate]);

For some reason the value of the token is being returned is null in prod even though in test it works fine. Need help on this.

Hey Sahir,

Thanks so much for posting!

We saw that you recently reached out in our community Slack channel and we’re working to get to the bottom of this there.

We’ll follow up here with a summary for posterity once we get things resolved in Slack!

Following up here for future reference, and for anyone else looking on!

It turns out that the query parameters included in the Magic Link redirect URL weren’t making it to Sahir’s production domain because of a default setting in their CDN that doesn’t forward query strings.

Different CDNs have different settings, but Cloudflare’s “Ignore Query String” setting is one example of this. Changing that setting resolved the issue!