Which frontend SDK do you use?
supertokens-auth-react
supertokens-web-js / mobile
API Base Path
Step 1) Back End Change#
The default apiBasePath is /auth. If you don't like that, or if you need to change it to make is similar to your other routes, you can do so by setting the apiBasePath config:
- NodeJS
- GoLang
- Python
import SuperTokens from "supertokens-node";
SuperTokens.init({ appInfo: { appName: "yourAppName", apiDomain: "yourApi", websiteDomain: "yourWebsite", apiBasePath: "/api/v3/auth" }, recipeList: [],});import "github.com/supertokens/supertokens-golang/supertokens"
func main() { apiBasePath := "/authentication" supertokens.Init(supertokens.TypeInput{ AppInfo: supertokens.AppInfo{ AppName: "yourAppName", APIDomain: "yourApi", WebsiteDomain: "yourWebsite", APIBasePath: &apiBasePath, }, })}from supertokens_python import init, InputAppInfo
init( app_info=InputAppInfo( app_name='yourAppName', website_domain='yourWebsite', api_domain='yourApi', api_base_path='/authentication' ), framework='...', recipe_list=[ #... ])Step 2) Front End Change#
You also need to change the apiBasePath in your frontend code:
- ReactJS
- Angular
- Vue
import SuperTokens from "supertokens-auth-react";
SuperTokens.init({ appInfo: { appName: "yourAppName", apiDomain: "yourApi", websiteDomain: "yourWebsite", apiBasePath: "/api/v3/auth" }, recipeList: [],});important
SuperTokens config changes need to be reflected in both supertokens-auth-react and supertokens-web-js configs.
/app/auth/supertokensAuthComponent.tsx
import SuperTokens from "supertokens-auth-react";
SuperTokens.init({ appInfo: { appName: "yourAppName", apiDomain: "yourApi", websiteDomain: "yourWebsite", apiBasePath: "/api/v3/auth" }, recipeList: [],});/app/app.component.ts
import SuperTokens from "supertokens-web-js";import Session from "supertokens-web-js/recipe/session";
SuperTokens.init({ appInfo: { apiDomain: "...", apiBasePath: "/api/v3/auth", appName: "...", }, recipeList: [ Session.init(), ],});important
SuperTokens config changes need to be reflected in both supertokens-auth-react and supertokens-web-js configs.
/components/Supertokens.tsx
import SuperTokens from "supertokens-auth-react";
SuperTokens.init({ appInfo: { appName: "yourAppName", apiDomain: "yourApi", websiteDomain: "yourWebsite", apiBasePath: "/api/v3/auth" }, recipeList: [],});/main.ts
import SuperTokens from "supertokens-web-js";import Session from "supertokens-web-js/recipe/session";
SuperTokens.init({ appInfo: { apiDomain: "...", apiBasePath: "/api/v3/auth", appName: "...", }, recipeList: [ Session.init(), ],});