Adding a base path
important
- This feature is only available for core versions >= 3.9
- This is applicable only to self hosted cores
If you cannot add a dedicated (sub) domain for the core and want to expose it to an external network, you may need to add a base path to all of the core APIs. To do this, you will have to make changes to the core's config as well as to the backend SDK's init
function call.
Let's take an example where we want the core to be located on http://localhost:3567/some-prefix
. This implies that all APIs exposed by the core will be on http://localhost:3567/some-prefix/*
.
Step 1. Core config change
docker run \
-p 3567:3567 \
// highlight-next-line
-e BASE_PATH="/some-prefix" \
-d registry.supertokens.io/supertokens/supertokens-<db_name>
Step 2. Backend SDK changes
import supertokens from "supertokens-node";
supertokens.init({
supertokens: {
connectionURI: "http://localhost:3567/some-prefix",
// ...
},
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "...",
},
recipeList: [/* ... */ ]
});
note
You can even set different base paths for different core instances:
- For each of the core's configs you need to supply their base path as mentioned in step 1
- The connection URI should be something like
"<core1-domain>/<core1-basePath>;<core2-domain>/<core2-basePath>;<core2-domain>/<core2-basePath>;"
. For example, a valid connection URI can be"http://localhost:3567/some-prefix;http://localhost:3567/some-prefix-2"