https://supertokens.com/ logo
n

Nashor

04/03/2022, 2:55 PM
Hello, I was playing with Supertokens using react and express, trying to just to get the auth page following the docs (https://supertokens.com/docs/thirdpartyemailpassword/quick-setup/frontend). SuperTokens.getRoutingComponent was not working until I have add (window as any).global = window; Is this missing in the document or was I doing something wrong?
r

rp

04/03/2022, 3:01 PM
Hey! You don’t need to assign to global in there.
Can u see how you are using getRoutingComponent?
n

Nashor

04/03/2022, 3:12 PM
Here are the ts files
Here is the error when the (window as any).global = window line is commented out
I'm using vite btw (don't know if relevant)
r

rp

04/03/2022, 3:46 PM
You need to make sure that
SuperTokens.canHandleRoute()
is called only on the client side
n

Nashor

04/03/2022, 3:51 PM
Hmm, how can I do that?
r

rp

04/03/2022, 3:52 PM
That you will have to see how it's done in vite
n

Nashor

04/03/2022, 3:52 PM
Ohh, didn't realize the ssr part of vite, I'll check it out. Thanks!
I think this is the reason why global does not exist, as you said it is coming from vite. So the (window as any).global = window becomes the solutions 😄 (vite issue link: https://github.com/vitejs/vite/issues/2778) Again, thanks for the support!
r

rp

04/03/2022, 4:36 PM
hmm. I see.
2 Views