Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow logging of core HTTP requests #865

Closed
jamalaberque opened this issue Oct 25, 2023 · 1 comment
Closed

Allow logging of core HTTP requests #865

jamalaberque opened this issue Oct 25, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jamalaberque
Copy link

🚀 Feature

Logging HTTP requests sent to the core allows users to monitor what traffic they send to SuperTokens, avoid flooding it for no reason, and comply with the new rate limits.

This should be functional for users of SuperTokens SaaS as well as self-hosted.

Implementation details

(Please outline any details about how this feature would e implemented. If you don't know, you can just skip this section.)

Discord thread

https://discord.com/channels/603466164219281420/1166656686644277259

@IamMayankThakur
Copy link

IamMayankThakur commented Nov 13, 2023

We've added support for a hook that intercepts all outgoing traffic from the SDK. This can be used to intercept as well as modify the request to the core. This feature has been added in all three sdks:

Here's a node snippet for how to use it. Detailed docs for all sdks will be up soon.

import EmailPassword from "supertokens-node/recipe/emailpassword";
import Session from "supertokens-node/recipe/session";
import { HttpRequest } from "supertokens-node/types";

SuperTokens.init({
            supertokens: {
                connectionURI,
                // new hook
                networkInterceptor: (request: HttpRequest, userContext: any) => {
                    console.log("http request to core: ", request)                    
                    return request; // this can also return a modified request object.
                },
            },
            appInfo: {
                apiDomain: "api.supertokens.io",
                appName: "SuperTokens",
                websiteDomain: "supertokens.io",
            },
            recipeList: [
                EmailPassword.init(),
                Session.init()m
            ],
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants