oldhack
11/24/2022, 11:42 PMnkshah2
11/25/2022, 1:09 AMoldhack
11/25/2022, 1:10 AMnkshah2
11/25/2022, 1:11 AMoldhack
11/25/2022, 1:13 AMimport EmailVerificationNode from 'supertokens-node/recipe/emailverification';
import ThirdPartyEmailPassword from 'supertokens-node/recipe/thirdpartyemailpassword';
import UserMetadata from 'supertokens-node/recipe/usermetadata';
import SessionNode from 'supertokens-node/recipe/session';
import { appInfo } from './appInfo';
import { TypeInput } from 'supertokens-node/types';
import Dashboard from 'supertokens-node/recipe/dashboard';
export const backendConfig = (): TypeInput => {
const recipeList = [ ThirdPartyEmailPassword.init({
providers: [
ThirdPartyEmailPassword.Google({
clientId: '***',
clientSecret: '***',
}),
],
}),
EmailVerificationNode.init({ mode: 'REQUIRED' }),
SessionNode.init({ jwt: { enable: true } }),
UserMetadata.init(),
];
if (process.env.NODE_ENV === 'development')
recipeList.push(
Dashboard.init({ apiKey: process.env.NEXT_SUPERTOKENS_DASHBOARD_KEY }),
);
return {
framework: 'express',
supertokens: {
connectionURI: process.env.NEXT_SUPERTOKENS_CONNECTION_URI,
apiKey: process.env.NEXT_SUPERTOKENS_APIKEY,
},
appInfo,
recipeList,
telemetry: process.env.NODE_ENV === 'development',
isInServerlessEnv: true,
};
nkshah2
11/25/2022, 1:14 AMoldhack
11/25/2022, 1:14 AMimport { AppInfo } from 'supertokens-node/types';
export const appInfo: AppInfo = {
// learn more about this on https://supertokens.com/docs/thirdpartyemailpassword/appinfo
appName: 'project1',
apiDomain: process.env.NEXT_PUBLIC_APP_DOMAIN,
websiteDomain: process.env.NEXT_PUBLIC_APP_DOMAIN,
apiBasePath: '/api/auth',
websiteBasePath: '/auth',
};
import ThirdPartyEmailPassword, {
Google,
} from 'supertokens-auth-react/recipe/thirdpartyemailpassword';
import SessionReact from 'supertokens-auth-react/recipe/session';
import { appInfo } from './appInfo';
export const frontendConfig = () => {
return {
appInfo,
recipeList: [
ThirdPartyEmailPassword.init({
signInAndUpFeature: {
providers: [Google.init()],
style: {
superTokensBranding: {
display: 'none',
},
},
},
getRedirectionURL: async (context) => {
if (context.action !== 'SUCCESS') return;
return context.redirectToPath || '/';
},
}),
SessionReact.init(),
],
};
};
nkshah2
11/25/2022, 1:16 AMoldhack
11/25/2022, 1:17 AMnkshah2
11/25/2022, 1:17 AMoldhack
11/25/2022, 1:19 AMapiBasePath: "/api/auth"
apiDomain: "http://localhost:3999"
appName: "project1"
websiteBasePath: "/auth"
websiteDomain: "http://localhost:3999"
Server:
app_1 | {
app_1 | appName: 'project1',
app_1 | apiDomain: 'http://localhost:3999',
app_1 | websiteDomain: 'http://localhost:3999',
app_1 | apiBasePath: '/api/auth',
app_1 | websiteBasePath: '/auth'
app_1 | }
nkshah2
11/25/2022, 1:20 AMoldhack
11/25/2022, 1:21 AMnkshah2
11/25/2022, 1:21 AMoldhack
11/25/2022, 1:22 AMnkshah2
11/25/2022, 1:23 AMoldhack
11/25/2022, 1:23 AM{
"message": "Please provide the thirdPartyId as a GET param"
}
nkshah2
11/25/2022, 1:24 AMoldhack
11/25/2022, 1:24 AMnkshah2
11/25/2022, 1:24 AMoldhack
11/25/2022, 1:25 AMnkshah2
11/25/2022, 1:25 AMoldhack
11/25/2022, 1:27 AMnkshah2
11/25/2022, 1:28 AMoldhack
11/25/2022, 1:28 AMnkshah2
11/25/2022, 1:30 AMoldhack
11/25/2022, 1:31 AMnkshah2
11/25/2022, 1:33 AMoldhack
11/25/2022, 1:35 AMnkshah2
11/25/2022, 1:35 AMoldhack
11/25/2022, 1:37 AMnkshah2
11/25/2022, 1:44 AMoldhack
11/25/2022, 1:45 AMnkshah2
11/25/2022, 1:45 AMrp
11/25/2022, 2:38 AMoldhack
11/25/2022, 2:44 AMrp
11/25/2022, 2:48 AMoldhack
11/25/2022, 2:51 AMrp
11/25/2022, 2:52 AMoldhack
11/25/2022, 2:53 AMrp
11/25/2022, 2:55 AMoldhack
11/25/2022, 2:56 AMrp
11/25/2022, 2:57 AMoldhack
11/25/2022, 2:57 AMrp
11/25/2022, 2:58 AMoldhack
11/25/2022, 2:58 AMrp
11/25/2022, 2:58 AMoldhack
11/25/2022, 2:58 AMrp
11/25/2022, 2:58 AMoldhack
11/25/2022, 2:59 AMrp
11/25/2022, 2:59 AMoldhack
11/25/2022, 3:00 AMrp
11/25/2022, 3:00 AMoldhack
11/25/2022, 3:01 AMrp
11/25/2022, 3:02 AMoldhack
11/25/2022, 3:40 AMrp
11/25/2022, 4:03 AM/auth
route directly, it redirects me to the /
route - which is expected.oldhack
11/25/2022, 11:57 AMrp
11/25/2022, 11:59 AMimport Router from 'next/router'
supertokens.init({
// ....
windowHandler: (oI: any) => {
return {
...oI,
location: {
...oI.location,
setHref: (href: string) => {
Router.push(href)
},
},
}
},
})
basically we are telling supertokens to use next router for navigation instead of doing a full reload. Full reload seems to cause nextjs to have this weird issue that you are facingoldhack
11/25/2022, 12:25 PMwindowHandler
, but, ignoring that, I still get redirectedrp
11/25/2022, 12:26 PMoldhack
11/25/2022, 12:28 PMconsole
anywhere inside the windowHandler, I don't see it getting logged on the FErp
11/25/2022, 12:29 PMoldhack
11/25/2022, 12:29 PM// eslint-disable-next-line @typescript-eslint/no-explicit-any
const windowHandler = (oI: any) => {
console.log('whats up');
return {
...oI,
location: {
...oI.location,
setHref: (href: string) => {
Router.push(href);
},
},
};
};
export const frontendConfig = () => {
return {
appInfo,
recipeList: [
ThirdPartyEmailPassword.init({
signInAndUpFeature: {
style: { superTokensBranding: { display: 'none' } },
},
getRedirectionURL: async (context) => {
if (context.action !== 'SUCCESS') return;
return context.redirectToPath || '/';
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
windowHandler,
}),
SessionReact.init(),
],
};
};
rp
11/25/2022, 12:32 PM