rp
04/30/2021, 12:53 PMmichaelzhuk
04/30/2021, 12:53 PMrp
04/30/2021, 12:54 PMmichaelzhuk
04/30/2021, 12:55 PMmichaelzhuk
04/30/2021, 12:56 PMexport let frontendConfig = () => {
return {
useReactRouterDom: false,
appInfo,
recipeList: [
ThirdPartyEmailPasswordReact.init({
signInAndUpFeature: {
providers: [],
},
async getRedirectionURL(context) {
console.log("> CONTEXT", context)
if (context.action === "SUCCESS") {
return "/brand"
}
},
onHandleEvent(context) {
switch (context.action) {
case "SUCCESS":
window.opener?.location.reload()
window.close()
}
},
}),
SessionReact.init(),
],
}
}
export let backendConfig = () => {
return {
supertokens: {
connectionURI: process.env.SUPERTOKENS_DOMAIN,
apiKey: process.env.SUPERTOKENS_API_KEY,
},
appInfo,
recipeList: [
ThirdPartyEmailPasswordNode.init({
signUpFeature: {
handlePostSignUp: async (user) => {
const { id, email } = user
try {
await fetchApi("/api/users/create", { id, email })
} catch (error) {
console.log("> Failed to sign up", error)
}
},
},
}),
SessionNode.init(),
],
isInServerlessEnv: true,
}
}
rp
04/30/2021, 12:57 PMappInfo
?michaelzhuk
04/30/2021, 12:58 PMlet appInfo = {
appName: "Off Script",
websiteDomain: siteUrl,
apiDomain: siteUrl,
apiBasePath: "/api/auth/",
}
siteUrl is the url where my app is runningrp
04/30/2021, 12:58 PMrp
04/30/2021, 12:58 PMmichaelzhuk
04/30/2021, 12:59 PMmichaelzhuk
04/30/2021, 1:03 PMsupertokens.init(SuperTokensConfig.backendConfig())
...
let session
try {
session = await getSession(req, res)
} catch (error) {
console.log("> INSERT ERROR", error)
return res.status(401).json({ error: "Unauthorized" })
}
rp
04/30/2021, 1:03 PMmichaelzhuk
04/30/2021, 1:04 PMmichaelzhuk
04/30/2021, 1:04 PM"supertokens-auth-react": "^0.9.0",
"supertokens-node": "^4.3.1",
rp
04/30/2021, 1:04 PMmichaelzhuk
04/30/2021, 1:05 PMrp
04/30/2021, 1:05 PMmichaelzhuk
04/30/2021, 1:09 PMgetSession
on the backend. Wondering how it possible?rp
04/30/2021, 1:10 PM/api/auth/session/refresh
which also needs to get cleared. And that can only be accessible if you navigate to that on your browser (if using chrome)rp
04/30/2021, 1:12 PMgetSession
would work with thatrp
04/30/2021, 1:13 PMapiDomain
and websiteDomain
are the same, i'm not sure how it's possible for antiCsrf to be enabled.. are you sure there is no where else where this anti-csrf is being set to true?michaelzhuk
04/30/2021, 1:16 PMkakashi_44
04/30/2021, 1:16 PMmichaelzhuk
04/30/2021, 1:17 PMmichaelzhuk
04/30/2021, 1:19 PMrp
04/30/2021, 1:29 PMrp
04/30/2021, 1:29 PMgetSession
, you should get unauthorised error. And then create a new session, and try to use thatrp
04/30/2021, 1:37 PMverifySession
instead of `getSession`: https://supertokens.io/docs/thirdpartyemailpassword/nextjs/session-verification/in-api#3-call-the-verifysession-session-functionrp
04/30/2021, 1:37 PMgetSession
throws multiple types of errors which are all handled by verifySession
rp
04/30/2021, 1:40 PM/tmp/supertokens-handshakeInfo