---
title: Add a base path
description: Configure a base path for self-hosted core APIs by updating core config and backend SDK.
sidebar:
  order: 6
---

## 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.

:::danger
A base path changes routing only. It does not authenticate requests, hide Core, or provide access control. Keep Core on a
private network reachable only by trusted backend services. If broader network reachability is unavoidable, also require
an API key, terminate TLS at a trusted edge, and restrict ingress with firewall or security-group rules.
:::

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

:::warning
This page is only relevant if you are self-hosting SuperTokens.
:::

The feature is only available for Core versions `>= 3.9`.


## Steps

### 1. Change the core configuration

<CodeGroup group="docker">
<Tab title="With Docker" value="with-docker">
```bash
 docker run \
    -p 127.0.0.1:3567:3567 \
    -e BASE_PATH="/some-prefix" \
    -d "$SUPERTOKENS_IMAGE"
```
</Tab>
<Tab title="Without Docker" value="without-docker">
```yaml
# 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"
```
</Tab>
</CodeGroup>

### 2. Change the backend SDK initialization

<CodeGroup group="backend-language">
<Tab title="Node.js" value="nodejs">
```tsx
import supertokens from "supertokens-node";

supertokens.init({
  supertokens: {
    connectionURI: "http://localhost:3567/some-prefix",
    // ...
  },
  appInfo: {
    apiDomain: "...",
    appName: "...",
    websiteDomain: "...",
  },
  recipeList: [
    /* ... */
  ],
});
```
</Tab>
<Tab title="Go" value="go">
```go
import "github.com/supertokens/supertokens-golang/supertokens"

func main() {
	supertokens.Init(supertokens.TypeInput{
		Supertokens: &supertokens.ConnectionInfo{
			ConnectionURI: "http://localhost:3567/some-prefix",
		},
	})
}
```
</Tab>
<Tab title="Python" value="python">
```python check=false reason="Partial configuration example"
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=[
      #...
   ]
)
```
</Tab>
</CodeGroup>

:::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>"`. For example, a valid connection URI is `"http://localhost:3567/some-prefix;http://localhost:3567/some-prefix-2"`.

:::
