Cannot call server function outside of a request
Tried to initialize Supertokens backend client in parallel with main router, but got this error:
Cannot call server function outside of a request
Supertokens client initializer:
entry-server:
I didn't fully understand how to segregate server-side code.9 Replies
You probably don’t want use server on that function anyway since it’s not something you’d call on the client
Only put use server on things you want to turn into api endpoints
so it won't leak in client if I import this module only in entry-server?
Yeah
You can make sure of it by throwing an error in the module if !isServer
looks boilerplaty but ok
It’s like 2 lines lol
is there any trpc examples so I can understand how segregation works?
I think there’s one in the repo
oh ok, tysm
I think with trpc you usually use an api route