Disabling APIs
- NodeJS
- GoLang
- Python
- Other Frameworks
Important
For other backend frameworks, you can follow our guide on how to spin up a separate server configured with the SuperTokens backend SDK to authenticate requests and issue session tokens.
To disable the API entirely, all you need to do is override the api implementation as undefined
.
For example, if you want to disable the sign-up and sign-in api, all you do is:
import SuperTokens from "supertokens-node";
import EmailPassword from "supertokens-node/recipe/emailpassword";
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
EmailPassword.init({
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,
signUpPOST: undefined,
signInPOST: undefined
}
}
}
})
]
});
To disable an API entirely, all you need to do is override the api implementation with nil
.
For example, if you want to disable the sign-up and sign-in api from this recipe, all you do is this:
import (
"github.com/supertokens/supertokens-golang/recipe/emailpassword"
"github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
supertokens.Init(supertokens.TypeInput{
RecipeList: []supertokens.Recipe{
emailpassword.Init(&epmodels.TypeInput{
Override: &epmodels.OverrideStruct{
APIs: func(originalImplementation epmodels.APIInterface) epmodels.APIInterface {
//First we copy the original impl
newImplementation := originalImplementation
// We disable the sign in and sign up APIs
newImplementation.SignInPOST = nil
newImplementation.SignUpPOST = nil
return newImplementation
},
},
}),
},
})
}
To disable an API entirely, all you need to do is override the api disable bool value to True
.
For example, if you want to disable the sign-up and sign-in api from this recipe, all you do is this:
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import emailpassword
from supertokens_python.recipe.emailpassword.interfaces import APIInterface
def apis_override(param: APIInterface):
param.disable_sign_in_post = True
param.disable_sign_up_post = True
return param
init(
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
emailpassword.init(
override=emailpassword.InputOverrideConfig(
apis=apis_override
)
)
]
)
important
You then need to define your own routes that will handle this API call. You can see the Frontend driver interface API spec here