Cannot call server function outside of a request
Tried to initialize Supertokens backend client in parallel with main router, but got this error:
Supertokens client initializer:
entry-server:
I didn't fully understand how to segregate server-side code.
Cannot call server function outside of a requestCannot call server function outside of a requestSupertokens client initializer:
"use server";
import supertokens from "supertokens-node";
import Session from "supertokens-node/recipe/session";
import EmailPassword from "supertokens-node/recipe/emailpassword";
export const initAuthServer = () => {
supertokens.init({
framework: "express",
supertokens: {
connectionURI:
"https://st-dev-5b734821-6414-11ef-8c62-03ca6dc7cc97.aws.supertokens.io",
apiKey: "a9ntJvmIYaQ-iWRUsLnGRDsWV-",
},
appInfo: {
appName: "ficlib",
apiDomain: "http://localhost:8000",
websiteDomain: "http://localhost:3000",
apiBasePath: "/auth",
websiteBasePath: "/auth",
},
recipeList: [EmailPassword.init(), Session.init()],
});
};"use server";
import supertokens from "supertokens-node";
import Session from "supertokens-node/recipe/session";
import EmailPassword from "supertokens-node/recipe/emailpassword";
export const initAuthServer = () => {
supertokens.init({
framework: "express",
supertokens: {
connectionURI:
"https://st-dev-5b734821-6414-11ef-8c62-03ca6dc7cc97.aws.supertokens.io",
apiKey: "a9ntJvmIYaQ-iWRUsLnGRDsWV-",
},
appInfo: {
appName: "ficlib",
apiDomain: "http://localhost:8000",
websiteDomain: "http://localhost:3000",
apiBasePath: "/auth",
websiteBasePath: "/auth",
},
recipeList: [EmailPassword.init(), Session.init()],
});
};entry-server:
import { createHandler, StartServer } from "@solidjs/start/server";
import { initAuthServer } from "./app/auth/server";
initAuthServer(); // usage
export default createHandler(() => (
<StartServer
document={({ assets, children, scripts }) => (
<html lang="en" class="dark">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
{assets}
</head>
<body>
<div id="app">{children}</div>
{scripts}
</body>
</html>
)}
/>
));import { createHandler, StartServer } from "@solidjs/start/server";
import { initAuthServer } from "./app/auth/server";
initAuthServer(); // usage
export default createHandler(() => (
<StartServer
document={({ assets, children, scripts }) => (
<html lang="en" class="dark">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
{assets}
</head>
<body>
<div id="app">{children}</div>
{scripts}
</body>
</html>
)}
/>
));I didn't fully understand how to segregate server-side code.

