---
title: Network interceptor
description: Intercept and modify outgoing backend SDK requests to the core in NodeJS, Python, and GoLang.
sidebar:
  order: 60
---

## Overview

This hook intercepts all outgoing requests from the backend SDK to the core.
Capture and modify the request before sending it to the core.
Users can modify the HTTP method, query params, headers, and body of the request.

## Prerequisites

:::info[Important]
This feature is only available for SDKs versions:
- NodeJS >= `v16.5.0`
- Python >= `v0.16.8`
- GoLang >= `v0.6.6`
:::

## Example 

<CodeGroup group="backend-language">
<Tab title="Node.js" value="nodejs">
```tsx
import { HttpRequest } from "supertokens-node/types";
import SuperTokens from "supertokens-node";

SuperTokens.init({
  supertokens: {
    connectionURI: "...",
    apiKey: "...",
    networkInterceptor: (request: HttpRequest, userContext: any) => {
      console.log("http request to core: ", request);
      // this can also be used to return a modified request object.
      return request;
    },
  },
  appInfo: {
    apiDomain: "...",
    appName: "...",
    websiteDomain: "...",
  },
  recipeList: [
    // ...
  ],
});
```
</Tab>
<Tab title="Go" value="go">
```go
import (
    "log"
    "net/http"

    "github.com/supertokens/supertokens-golang/supertokens"
)

func main() {
supertokens.Init(supertokens.TypeInput{
        Supertokens: &supertokens.ConnectionInfo{
            ConnectionURI: "...",
            APIKey: "...",
            NetworkInterceptor: func(request *http.Request, context supertokens.UserContext) (*http.Request, error) {
				log.Print("http request to core: %+v", request)
				return request, nil
			},
        },
        AppInfo: supertokens.AppInfo{
            AppName: "...",
            APIDomain: "...",
            WebsiteDomain: "...",
        },
        RecipeList: []supertokens.Recipe{/*...*/},
    })
}
```
</Tab>
<Tab title="Python" value="python">
```python
from typing import Dict, Any, Optional
from supertokens_python import init, InputAppInfo, SupertokensConfig

def intercept(
    url: str,
    method: str,
    headers: Dict[str, Any],
    params: Optional[Dict[str, Any]],
    body: Optional[Dict[str, Any]],
    user_context: Optional[Dict[str, Any]],
):
    print("http request to core: ", url, method, headers, params, body)
    return url, method, headers, params, body

init(
    app_info=InputAppInfo(
        app_name="...",
        api_domain="...",
        website_domain="...",
    ),
    supertokens_config=SupertokensConfig(
        connection_uri="...",
        api_key="...",
        network_interceptor=intercept,
    ),
    framework="django",  # works with other frameworks as well
    recipe_list=[
        # ...
    ],
)
```
</Tab>
</CodeGroup>
