API Base Path
#
Step 1) Back End ChangeThe 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
- Other Frameworks
Important
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 ChangeYou also need to change the apiBasePath
in your frontend code:
- ReactJS
- Angular
- Vue
You will have to make changes to the auth route config, as well as to the supertokens-web-js
SDK config at the root of your application:
This change is in your auth route config.
// this goes in the auth route config of your frontend app (once the pre built UI script has been loaded)
supertokensUIInit("supertokensui", {
appInfo: {
appName: "yourAppName",
apiDomain: "yourApi",
websiteDomain: "yourWebsite",
apiBasePath: "/api/v3/auth"
},
recipeList: [],
});
This change goes in the supertokens-web-js
SDK config at the root of your application:
// this goes in the root of your frontend app
import SuperTokens from "supertokens-web-js";
SuperTokens.init({
appInfo: {
apiDomain: "...",
apiBasePath: "/api/v3/auth",
appName: "...",
},
recipeList: [/* ... */],
});
import SuperTokens from "supertokens-auth-react";
SuperTokens.init({
appInfo: {
appName: "yourAppName",
apiDomain: "yourApi",
websiteDomain: "yourWebsite",
apiBasePath: "/api/v3/auth"
},
recipeList: [],
});
You will have to make changes to the auth route config, as well as to the supertokens-web-js
SDK config at the root of your application:
This change is in your auth route config.
// this goes in the auth route config of your frontend app (once the pre built UI script has been loaded)
supertokensUIInit("supertokensui", {
appInfo: {
appName: "yourAppName",
apiDomain: "yourApi",
websiteDomain: "yourWebsite",
apiBasePath: "/api/v3/auth"
},
recipeList: [],
});
This change goes in the supertokens-web-js
SDK config at the root of your application:
// this goes in the root of your frontend app
import SuperTokens from "supertokens-web-js";
SuperTokens.init({
appInfo: {
apiDomain: "...",
apiBasePath: "/api/v3/auth",
appName: "...",
},
recipeList: [/* ... */],
});