Skip to main content

2. Backend config

1) Install supertokens package#

npm i supertokens-node

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

  • Create a config folder in the root directory of your project.
  • Create a supertokensConfig.js inside the config folder.
  • 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.
  • You can also use process.env.SITE_NAME + "" as the value for websiteDomain and for apiDomain.
  • Be sure to add apiBasePath: "/.netlify/functions/auth" as well in the appInfo object. To learn more about this config, please visit the appInfo page.

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", // Example: "http://localhost:8080",      websiteDomain: "YOUR WEBSITE DOMAIN", // Example: "http://localhost:8080"      apiBasePath: "/.netlify/functions/auth"    },    recipeList: [      EmailPassword.init(),      Session.init(),    ],    isInServerlessEnv: true,  }}
module.exports.getBackendConfig = getBackendConfig;