supertokens / supertokens-auth-react

ReactJS authentication module for SuperTokens
https://supertokens.com
Other
282 stars 88 forks source link

Double verification mails #423

Closed budasnorbi closed 2 years ago

budasnorbi commented 2 years ago

Hey, I would like to report an issue about reactStrictMode: true at Next.js.

I got this setting default to true when generated the project. When i successfully signed up i got two email address verification emails. After a suggestion to change reactStrictMode to false it worked the way it should and i only got one mail.

I used the EmailPassword recipe.

Framework: Next.js

  "dependencies": {
    "axios": "^0.26.1",
    "next": "12.1.2",
    "nextjs-cors": "^2.1.1",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "supertokens-auth-react": "^0.20.3"
  },
  "optionalDependencies": {
    "@next/swc-linux-arm64-gnu": "^11.1.3-canary.104",
    "@next/swc-linux-arm64-musl": "^11.1.3-canary.104"
  },
  "devDependencies": {
    "@types/node": "17.0.23",
    "@types/react": "17.0.43",
    "@types/react-dom": "17.0.14",
    "eslint": "8.12.0",
    "eslint-config-next": "12.1.2",
    "typescript": "4.6.3"
  }

Pages

auth/[[...path]].tsx:

import React, { useEffect } from "react";
import dynamic from "next/dynamic";
import SuperTokens from "supertokens-auth-react";
import { redirectToAuth } from "supertokens-auth-react/recipe/emailpassword";

const SuperTokensComponentNoSSR = dynamic(
  new Promise((res) => res(SuperTokens.getRoutingComponent)) as any,
  { ssr: false }
);

export default function Auth() {
  useEffect(() => {
    if (SuperTokens.canHandleRoute() === false) {
      redirectToAuth();
    }
  }, []);

  return (
    <main>
      <SuperTokensComponentNoSSR />
    </main>
  );
}

_app.tsx

import React, { useEffect } from "react";
import { AppProps } from "next/app";
import SuperTokensReact from "supertokens-auth-react";
import EmailPasswordReact from "supertokens-auth-react/recipe/emailpassword";
import SessionReact from "supertokens-auth-react/recipe/session";

if (typeof window !== "undefined") {
  SuperTokensReact.init({
    appInfo: {
      appName: "test-app",
      apiDomain: "http://localhost:3001/",
      websiteDomain: "http://localhost:3000",
      apiBasePath: "/auth",
      websiteBasePath: "/auth"
    },
    recipeList: [
      EmailPasswordReact.init({
        useShadowDom: false,
        override: {
          components: {
            EmailPasswordSignUpForm_Override: ({
              DefaultComponent,
              ...props
            }) => {
              useEffect(() => {
                const passwordConfirm =
                  document.querySelector<HTMLInputElement>(
                    '.supertokens-input[name="passwordConfirm"]'
                  );

                if (passwordConfirm && passwordConfirm.type === "text") {
                  passwordConfirm.setAttribute("type", "password");
                }
              }, []);
              return <DefaultComponent {...props} />;
            }
          }
        },
        emailVerificationFeature: {
          mode: "REQUIRED"
        },
        style: {
          input: {
            backgroundColor: "white"
          },
          superTokensBranding: {
            display: "none"
          }
        },
        signInAndUpFeature: {
          signUpForm: {
            formFields: [
              {
                id: "passwordConfirm",
                label: "Jelszó megerősítése",
                placeholder: "",
                type: "password",
                validate: async (value: string) => {
                  const passwordField =
                    document.querySelector<HTMLInputElement>(
                      '.supertokens-input[name="password"]'
                    );

                  if (value !== passwordField?.value) {
                    return "A jelszó és a jelszó megerősítő mezők nem egyeznek";
                  }
                  return undefined;
                }
              },
              {
                id: "firstName",
                label: "Vezetéknév",
                placeholder: ""
              },
              {
                id: "lastName",
                label: "Keresztnév",
                placeholder: ""
              },
              { id: "email", label: "Email cím", placeholder: "" },
              {
                id: "password",
                label: "Jelszó",
                placeholder: "",
                validate: async (value: string) => {
                  if (value.length < 8) {
                    return "A jelszó túl rövid";
                  }
                  if (value.length > 64) {
                    return "A jelszó túl hosszú";
                  }
                  return undefined;
                }
              }
            ]
          }
        }
      }),
      SessionReact.init()
    ]
  });
}

function MyApp({ Component, pageProps }: AppProps) {
  return <Component {...pageProps} />;
}

export default MyApp;

index.ts

import dynamic from "next/dynamic";
import React from "react";
import { EmailPasswordAuth } from "supertokens-auth-react/recipe/emailpassword";

const EmailPasswordAuthNoSSR = dynamic(
  new Promise((res) => res(EmailPasswordAuth)) as any,
  { ssr: false }
);

export default function Home() {
  return (
    <EmailPasswordAuthNoSSR>
      <div>test</div>
    </EmailPasswordAuthNoSSR>
  );
}

After enabling troubleshoot on the supertokens backend SDK I got theese logs:

2022-04-13T12:55:59.272Z com.supertokens {t: "2022-04-13T12:55:59.267Z", message: "Started SuperTokens with debug logging (supertokens.init called)", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:270:18" sdkVer: "9.1.2"}
2022-04-13T12:55:59.273Z com.supertokens {t: "2022-04-13T12:55:59.273Z", message: "appInfo: {"appName":"smart-warehouse","apiDomain":"http://localhost:3001/","websiteDomain":"http://localhost:3000","apiBasePath":"/auth","websiteBasePath":"/auth"}", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:271:18" sdkVer: "9.1.2"}               
2022-04-13T12:55:59.274Z com.supertokens {t: "2022-04-13T12:55:59.274Z", message: "framework: express", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:273:18" sdkVer: "9.1.2"}
2022-04-13T12:55:59.277Z com.supertokens {t: "2022-04-13T12:55:59.276Z", message: "session init: antiCsrf: NONE", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:164:18" sdkVer: "9.1.2"}
2022-04-13T12:55:59.277Z com.supertokens {t: "2022-04-13T12:55:59.277Z", message: "session init: cookieDomain: undefined", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:165:18" sdkVer: "9.1.2"}               
2022-04-13T12:55:59.278Z com.supertokens {t: "2022-04-13T12:55:59.278Z", message: "session init: cookieSameSite: lax", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:166:18" sdkVer: "9.1.2"}               
2022-04-13T12:55:59.278Z com.supertokens {t: "2022-04-13T12:55:59.278Z", message: "session init: cookieSecure: false", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:167:18" sdkVer: "9.1.2"}               
2022-04-13T12:55:59.278Z com.supertokens {t: "2022-04-13T12:55:59.278Z", message: "session init: refreshTokenPath: /auth/session/refresh", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:168:18" sdkVer: "9.1.2"}               
2022-04-13T12:55:59.279Z com.supertokens {t: "2022-04-13T12:55:59.278Z", message: "session init: sessionExpiredStatusCode: 401", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:171:18" sdkVer: "9.1.2"}               
2022-04-13T12:56:04.527Z com.supertokens {t: "2022-04-13T12:56:04.526Z", message: "middleware: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:04.529Z com.supertokens {t: "2022-04-13T12:56:04.529Z", message: "middleware: requestRID is: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
2022-04-13T12:56:04.530Z com.supertokens {t: "2022-04-13T12:56:04.529Z", message: "middleware: Checking recipe ID for match: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}               
2022-04-13T12:56:04.530Z com.supertokens {t: "2022-04-13T12:56:04.530Z", message: "middleware: Matched with recipe ID: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:04.532Z com.supertokens {t: "2022-04-13T12:56:04.531Z", message: "middleware: Request being handled by recipe. ID is: /signup/email/exists", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}
2022-04-13T12:56:04.570Z com.supertokens {t: "2022-04-13T12:56:04.569Z", message: "Sending response to client with status code: 200", file: "/usr/backend/node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}               
2022-04-13T12:56:04.572Z com.supertokens {t: "2022-04-13T12:56:04.572Z", message: "middleware: Ended", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:215:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:19.694Z com.supertokens {t: "2022-04-13T12:56:19.694Z", message: "middleware: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:19.696Z com.supertokens {t: "2022-04-13T12:56:19.695Z", message: "middleware: requestRID is: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
2022-04-13T12:56:19.697Z com.supertokens {t: "2022-04-13T12:56:19.696Z", message: "middleware: Checking recipe ID for match: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}               
2022-04-13T12:56:19.698Z com.supertokens {t: "2022-04-13T12:56:19.697Z", message: "middleware: Matched with recipe ID: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:19.700Z com.supertokens {t: "2022-04-13T12:56:19.699Z", message: "middleware: Request being handled by recipe. ID is: /signup", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.045Z com.supertokens {t: "2022-04-13T12:56:20.044Z", message: "Sending response to client with status code: 200", file: "/usr/backend/node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.046Z com.supertokens {t: "2022-04-13T12:56:20.046Z", message: "middleware: Ended", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:215:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.804Z com.supertokens {t: "2022-04-13T12:56:20.802Z", message: "middleware: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.806Z com.supertokens {t: "2022-04-13T12:56:20.805Z", message: "middleware: requestRID is: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
2022-04-13T12:56:20.806Z com.supertokens {t: "2022-04-13T12:56:20.806Z", message: "middleware: Checking recipe ID for match: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.807Z com.supertokens {t: "2022-04-13T12:56:20.806Z", message: "middleware: Matched with recipe ID: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.809Z com.supertokens {t: "2022-04-13T12:56:20.809Z", message: "middleware: Request being handled by recipe. ID is: /user/email/verify", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.819Z com.supertokens {t: "2022-04-13T12:56:20.811Z", message: "getSession: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:142:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.820Z com.supertokens {t: "2022-04-13T12:56:20.820Z", message: "getSession: rid in header: true", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:153:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.822Z com.supertokens {t: "2022-04-13T12:56:20.820Z", message: "getSession: request method: get", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:154:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.832Z com.supertokens {t: "2022-04-13T12:56:20.824Z", message: "getSession: Value of doAntiCsrfCheck is: false", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:207:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.857Z com.supertokens {t: "2022-04-13T12:56:20.856Z", message: "getSession: Success!", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:230:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.897Z com.supertokens {t: "2022-04-13T12:56:20.897Z", message: "Sending response to client with status code: 200", file: "/usr/backend/node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.901Z com.supertokens {t: "2022-04-13T12:56:20.898Z", message: "middleware: Ended", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:215:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.906Z com.supertokens {t: "2022-04-13T12:56:20.905Z", message: "middleware: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.906Z com.supertokens {t: "2022-04-13T12:56:20.906Z", message: "middleware: requestRID is: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
2022-04-13T12:56:20.908Z com.supertokens {t: "2022-04-13T12:56:20.906Z", message: "middleware: Checking recipe ID for match: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.909Z com.supertokens {t: "2022-04-13T12:56:20.908Z", message: "middleware: Matched with recipe ID: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.913Z com.supertokens {t: "2022-04-13T12:56:20.912Z", message: "middleware: Request being handled by recipe. ID is: /user/email/verify", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.914Z com.supertokens {t: "2022-04-13T12:56:20.914Z", message: "getSession: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:142:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.917Z com.supertokens {t: "2022-04-13T12:56:20.914Z", message: "getSession: rid in header: true", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:153:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.918Z com.supertokens {t: "2022-04-13T12:56:20.917Z", message: "getSession: request method: get", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:154:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.920Z com.supertokens {t: "2022-04-13T12:56:20.918Z", message: "getSession: Value of doAntiCsrfCheck is: false", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:207:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.922Z com.supertokens {t: "2022-04-13T12:56:20.921Z", message: "getSession: Success!", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:230:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.953Z com.supertokens {t: "2022-04-13T12:56:20.953Z", message: "middleware: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.957Z com.supertokens {t: "2022-04-13T12:56:20.954Z", message: "middleware: requestRID is: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
2022-04-13T12:56:20.957Z com.supertokens {t: "2022-04-13T12:56:20.957Z", message: "middleware: Checking recipe ID for match: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.958Z com.supertokens {t: "2022-04-13T12:56:20.958Z", message: "middleware: Matched with recipe ID: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.962Z com.supertokens {t: "2022-04-13T12:56:20.959Z", message: "middleware: Request being handled by recipe. ID is: /user/email/verify/token", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.976Z com.supertokens {t: "2022-04-13T12:56:20.966Z", message: "getSession: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:142:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.985Z com.supertokens {t: "2022-04-13T12:56:20.979Z", message: "getSession: rid in header: true", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:153:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.986Z com.supertokens {t: "2022-04-13T12:56:20.985Z", message: "getSession: request method: post", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:154:26" sdkVer: "9.1.2"}
2022-04-13T12:56:20.986Z com.supertokens {t: "2022-04-13T12:56:20.986Z", message: "getSession: Value of doAntiCsrfCheck is: true", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:207:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.990Z com.supertokens {t: "2022-04-13T12:56:20.989Z", message: "getSession: Success!", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:230:30" sdkVer: "9.1.2"}
2022-04-13T12:56:20.997Z com.supertokens {t: "2022-04-13T12:56:20.997Z", message: "middleware: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:20.998Z com.supertokens {t: "2022-04-13T12:56:20.997Z", message: "middleware: requestRID is: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.1.2"}
2022-04-13T12:56:20.999Z com.supertokens {t: "2022-04-13T12:56:20.998Z", message: "middleware: Checking recipe ID for match: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:181:34" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.000Z com.supertokens {t: "2022-04-13T12:56:20.999Z", message: "middleware: Matched with recipe ID: emailpassword", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:194:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.001Z com.supertokens {t: "2022-04-13T12:56:21.001Z", message: "middleware: Request being handled by recipe. ID is: /user/email/verify/token", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:206:30" sdkVer: "9.1.2"}
2022-04-13T12:56:21.001Z com.supertokens {t: "2022-04-13T12:56:21.001Z", message: "getSession: Started", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:142:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.002Z com.supertokens {t: "2022-04-13T12:56:21.002Z", message: "getSession: rid in header: true", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:153:26" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.003Z com.supertokens {t: "2022-04-13T12:56:21.003Z", message: "getSession: request method: post", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:154:26" sdkVer: "9.1.2"}
2022-04-13T12:56:21.003Z com.supertokens {t: "2022-04-13T12:56:21.003Z", message: "getSession: Value of doAntiCsrfCheck is: true", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:207:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.011Z com.supertokens {t: "2022-04-13T12:56:21.005Z", message: "getSession: Success!", file: "/usr/backend/node_modules/supertokens-node/lib/build/recipe/session/recipeImplementation.js:230:30" sdkVer: "9.1.2"}
2022-04-13T12:56:21.014Z com.supertokens {t: "2022-04-13T12:56:21.014Z", message: "Sending response to client with status code: 200", file: "/usr/backend/node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.015Z com.supertokens {t: "2022-04-13T12:56:21.015Z", message: "middleware: Ended", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:215:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.073Z com.supertokens {t: "2022-04-13T12:56:21.072Z", message: "Sending response to client with status code: 200", file: "/usr/backend/node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.074Z com.supertokens {t: "2022-04-13T12:56:21.073Z", message: "middleware: Ended", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:215:30" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.076Z com.supertokens {t: "2022-04-13T12:56:21.075Z", message: "Sending response to client with status code: 200", file: "/usr/backend/node_modules/supertokens-node/lib/build/utils.js:90:14" sdkVer: "9.1.2"}               
2022-04-13T12:56:21.077Z com.supertokens {t: "2022-04-13T12:56:21.077Z", message: "middleware: Ended", file: "/usr/backend/node_modules/supertokens-node/lib/build/supertokens.js:215:30" sdkVer: "9.1.2"} 
rishabhpoddar commented 2 years ago

hey @budasnorbi thanks for the detailed issue.

As per react, their strict mode should call a few react hooks twice during development mode to catch unexpected side effects. This list doesn't include useEffect which is what we use to make a call to the backend to send the email verification email. Also this is only for development builds.

However, in nextjs, even useEffect is called twice - I'm not sure why. And again, this happens only in development mode.

Maybe try react strict mode on and make a production build - does it still send the email twice?

budasnorbi commented 2 years ago

Yes, i can confirm that. Strict mode works with production build. Got one mail.

rishabhpoddar commented 2 years ago

Sounds good. So i am closing this issue.