Hi @katab,
Welcome to the Community!
I am not sure the exact error here, but have you considered using one of our SDKs? It will help to simplify the process.
This is our SPA js sdk:
https://auth0.com/docs/libraries/auth0-spa-js
And we recently released a react specific SDK in a public beta: