Add a base path
Configure a base path for self-hosted core APIs by updating core config and backend SDK.
Overview
If you cannot add a dedicated subdomain for Core, you can add a base path to all Core APIs.
To do this, you have to make changes to the core’s configuration as well as to the backend SDK’s init function call.
Consider an example where the core resides on http://localhost:3567/some-prefix. This implies that all APIs exposed by the core are on http://localhost:3567/some-prefix/*.
Before you start
The feature is only available for Core versions >= 3.9.
Steps
1. Change the core configuration
docker run \
-p 127.0.0.1:3567:3567 \
-e BASE_PATH="/some-prefix" \
-d "$SUPERTOKENS_IMAGE"# You need to add the following to the config.yaml file.
# The file path can be found by running the "supertokens --help" command
base_path: "/some-prefix"2. Change the backend SDK initialization
import supertokens from "supertokens-node";
supertokens.init({
supertokens: {
connectionURI: "http://localhost:3567/some-prefix",
// ...
},
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "...",
},
recipeList: [
/* ... */
],
});import "github.com/supertokens/supertokens-golang/supertokens"
func main() {
supertokens.Init(supertokens.TypeInput{
Supertokens: &supertokens.ConnectionInfo{
ConnectionURI: "http://localhost:3567/some-prefix",
},
})
}from supertokens_python import init, InputAppInfo, SupertokensConfig
init(
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
supertokens_config=SupertokensConfig(
connection_uri='http://localhost:3567/some-prefix',
),
framework='...',
recipe_list=[
#...
]
)