Skip to main content

2. Backend config

1) Install supertokens package#

npm i supertokens-node

2) Create a configuration file (config.js)#

  • Create a config.js file in the root directory of your project.
  • An example of this file can be found here.

3) Create a backend config function#

This function will return the config object used to configure supertokens-node:

  • All configuration options can be found here.
  • You will need to replace the supertokens object's connectionURI with the location of your core. You may also need to add an apiKey.
  • Notice the apiGatewayPath property in the appInfo config. The value of this should be the same as what you set on the frontend.

let EmailPassword = require('supertokens-node/recipe/emailpassword');let Session = require('supertokens-node/recipe/session')
function getBackendConfig() {  return {    supertokens: {      connectionURI: '',    },    appInfo: {      // learn more about this on      appName: "YOUR APP NAME", // Example: "SuperTokens",      apiDomain: "YOUR API DOMAIN", // This should be same as the domain name of your API Gateway. Example:      websiteDomain: "YOUR WEBSITE DOMAIN", // Example: "http://localhost:8080",      apiGatewayPath: "/dev" // same as what's set on the frontend config    },    recipeList: [      EmailPassword.init(),      Session.init(),    ],    isInServerlessEnv: true,  }}
module.exports.getBackendConfig = getBackendConfig;