https://supertokens.com/ logo
Title
d

DavidK

10/28/2022, 11:34 AM
Hi, I'm using prebuilt UI from supertokens. I'm trying to connect backend to MySql DB, but I'm having basic error (POST method in signin up or signin in) I'm using NodeJS and React in frontend
n

nkshah2

10/28/2022, 11:46 AM
Hi @DavidK , Can I see the config you use when initialising SuperTokens on the frontend and backend?
d

DavidK

10/28/2022, 11:48 AM
import EmailPassword from "supertokens-node/recipe/emailpassword";
import Session from "supertokens-node/recipe/session";
import { TypeInput } from "supertokens-node/types";
import Dashboard from "supertokens-node/recipe/dashboard";

export const SuperTokensConfig: TypeInput = {
    supertokens: {
        // this is the location of the SuperTokens core.
        connectionURI: "https://2c93283155d511ed82687d99624be41d-eu-west-1.aws.supertokens.io:3573",
        // connectionURI: "http://localhost:3567",
        apiKey: "jLc-owsMYZMSzGSdo5PKnvZsnoQz8J"
    },
    appInfo: {
        appName: "todo-lista",
        apiDomain: "http://localhost:3001",
        websiteDomain: "http://localhost:3000",
        apiBasePath: "/authapi",
        websiteBasePath: "/todolist",
    },
    // recipeList contains all the modules that you want to
    // use from SuperTokens. See the full list here: https://supertokens.com/docs/guides
    recipeList: [
        EmailPassword.init(), 
        Session.init(),
        Dashboard.init({
            apiKey: "jLc-owsMYZMSzGSdo5PKnvZsnoQz8J"
        }),
    ],
};
import EmailPassword from "supertokens-auth-react/recipe/emailpassword";
import Session from "supertokens-auth-react/recipe/session";

export const SuperTokensConfig = {
    appInfo: {
        appName: "SuperTokens Demo App",
        apiDomain: "http://localhost:3000",
        websiteDomain: "http://localhost:3000",
    },
    // recipeList contains all the modules that you want to
    // use from SuperTokens. See the full list here: https://supertokens.com/docs/guides
    recipeList: [EmailPassword.init(), Session.init()],
};
n

nkshah2

10/28/2022, 11:50 AM
apiDomain: "http://localhost:3000"
Should use port 3001
On the backend youve set it to
apiDomain: "http://localhost:3001"
You also have to set apiBasePath and websiteBasePath in the frontend config
d

DavidK

10/28/2022, 12:03 PM
wow I have missed this step.. Thanks a lot! Could you help me setting up database to save registered user?
r

rp

10/28/2022, 12:25 PM
hey @DavidK checkout our docs for this please
d

DavidK

10/28/2022, 12:34 PM
yo @rp thanks for the docs, but I've been following them and I can't get a single userid or email from DB
DB:
r

rp

10/28/2022, 12:36 PM
so the tables were created when u started the core - this means the core connected to the db just fine
can i see the core's output logs?
d

DavidK

10/28/2022, 12:37 PM
r

rp

10/28/2022, 12:38 PM
huh.. so this means the core hasn't connected to the db. Whats the location of the config.yaml file that you changed?
d

DavidK

10/28/2022, 12:38 PM
C:\Program Files\supertokens
r

rp

10/28/2022, 12:39 PM
I see that
mysql_connection_uri
is commented out in the file
you need to remove the
#
before that config and restart the core
d

DavidK

10/28/2022, 12:52 PM
Oh okay, I've done it and I've got still zero results in db
r

rp

10/28/2022, 12:53 PM
did you restart the core? What are the logs on start?
d

DavidK

10/28/2022, 12:53 PM
yes I've restarted
r

rp

10/28/2022, 12:54 PM
It does say that it has connected to mysql
d

DavidK

10/28/2022, 12:55 PM
I see, but in which table should I see the user?
r

rp

10/28/2022, 12:55 PM
can you sign up on the app, and then restart the core and then see if you can sign in with the user?
d

DavidK

10/28/2022, 12:56 PM
okay, gimme sec
I've restarted the core and automatically got this screen:
r

rp

10/28/2022, 12:57 PM
logout and sign in again
d

DavidK

10/28/2022, 12:58 PM
Yep it works
where could I see that user?
r

rp

10/28/2022, 12:58 PM
so it is saving in the db
d

DavidK

10/28/2022, 12:58 PM
But in which table? 😄
r

rp

10/28/2022, 12:58 PM
which db are you quering? and which login method did you use?
check the session_info table
check the emailpassword_users table (if you used email / password to sign up)
d

DavidK

10/28/2022, 1:00 PM
mysql, email password method session_info table empty
also emailpassword_users table empty
that's quite strange I guess
without docker
r

rp

10/28/2022, 1:14 PM
im not sure how this is possible
but the core is definitely connetcted to mysql
d

DavidK

10/28/2022, 1:15 PM
maybe this host or port is wrong?
or somethin.. dunno :/
r

rp

10/28/2022, 1:16 PM
Well.. not sure. Check which db you are querying. It seems like a different db than the one the core is connected to.
d

DavidK

10/28/2022, 1:17 PM
Does the config.yaml has to be in same path/folder like the whole core setup?
r

rp

10/28/2022, 1:17 PM
Yes
d

DavidK

10/28/2022, 1:18 PM
So I should only put config.yaml from this folder to the exact path of the core setup?
or somethin else?
r

rp

10/28/2022, 1:22 PM
There is already a config yaml in the installation path. Edit that
d

DavidK

10/28/2022, 1:23 PM
Hm this is what I have