Hi folks, I'm having trouble using axios in a quasar (vue3) vite project with supertokens alongside ...
j

jmark

about 2 years ago
Hi folks, I'm having trouble using axios in a quasar (vue3) vite project with supertokens alongside hasura, as far as I can tell the interceptor needed for axios only exists in the react-native supertokens package as the one in supertokens-web-js is deprecated and doesn't seem to let me use the interceptor. When I import the react-native supertokens package in my project the build fails, I've tried it in both vite and webpack with similar results. The vite error is:
7:52:14 PM [vite] error while updating dependencies:
Error: Build failed with 2 errors:
node_modules/react-native/Libraries/Utilities/PolyfillFunctions.js:28:31: ERROR: Expected "(" but found "<"
node_modules/react-native/index.js:14:7: ERROR: Unexpected "typeof"
    at failureErrorWithLog (C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:1621:15)
    at C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:1263:28
    at runOnEndCallbacks (C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:1043:63)
    at buildResponseToResult (C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:1261:7)
    at C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:1374:14
    at C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:675:9
    at handleIncomingPacket (C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:772:9)
    at Socket.readFromStdout (C:\Users\Josh\Documents\api-testing\ui-selfhosted\node_modules\esbuild\lib\main.js:641:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:315:12)
Vite Error, /node_modules/.q-cache/vite/spa/deps/supertokens-react-native.js?v=c3ec6ab7 optimized info should be defined
Any ideas on how I can get this working with vite, I've had no luck trying the various solutions I've found on google so far.
Hi, I'm having issues with email verification - it runs fine on my local dev server, but as soon as ...
k

Kranos

almost 2 years ago
Hi, I'm having issues with email verification - it runs fine on my local dev server, but as soon as I run a local build server I get the issue, so I think it's something to do with my build process. I'm running a vue.js app on a Fast API backend and I've double checked my implementation with the documentation to check I haven't missed anything. I'm running a managed development supertokens core. The issue I have is that when I click the email verification link, I get a 404 error. As per my set up, the email verification link is localhost:3000/auth/verify-email?token=SOME_TOKEN&rid=emailverification In my vue.js router at /auth/verify-email I have a vue.js component that loads and there is a checkAuth function that runs beforeEnter as follows:
async function checkAuth(to, from, next) {
  const canAccess = await Session.doesSessionExist();
  if (!canAccess) return next("/signin");
  else return next();
}
In my vue.js component that loads at /auth/verify-email I have a consumeVerificationCode() function that runs on mounted, having checked if there's a Session as per the documentation, see below:
async mounted() {
    if (!this.session) {
      await this.getSession();
      this.consumeVerificationCode();
    } else if (this.session) {
      this.consumeVerificationCode();
    }
  },
The consumeVerificationCode() function is as follows:
async consumeVerificationCode() {
      try {
        let response = await verifyEmail();
        if (response.status === "EMAIL_VERIFICATION_INVALID_TOKEN_ERROR") {
          // This can happen if the verification code is expired or invalid.
          // You should ask the user to retry
          toast.error(
            "Oops! Seems like the verification link expired. Please try again later."
          );
          this.$router.push("/auth/verify-email"); // back to the email sending screen.
        } else {
          // email was verified successfully.
          toast.success("Email verified successfully!");
          this.$router.push(this.userId + "/onboarding");
        }
      } catch (err) {
        if (err.isSuperTokensGeneralError === true) {
          // this may be a custom error message sent from the API by you.
          toast.error(err.message);
        } else {
          toast.error(
            "Oops! Seems like the verification link expired. Please try again later."
          );
        }
      }
    },
verifyEmail is imported as follows:
import { verifyEmail } from "supertokens-web-js/recipe/emailverification";
The 404 error I receive isn't my custom 404 page - it displays what's seen in the attachment below