Is there a health check endpoint for the service u...
# support-questions-legacy
a
Is there a health check endpoint for the service using the backend sdk? I mean is there a healthcheck route that the middy middleware injects? I know there is one for supertokens-core.
r
hey @aktopian you can add your own healthcheck endpoint like this:
Copy code
supertokens.init(getBackendConfig());

module.exports.handler = middy(
    middleware((event) => {
            return {
                body: JSON.stringify({
                    msg: "Hello!",
                }),
                statusCode: 200,
            };
    })
)
    .use(
        cors({
            origin: getBackendConfig().appInfo.websiteDomain,
            credentials: true,
            headers: ["Content-Type", ...supertokens.getAllCORSHeaders()].join(", "),
            methods: "OPTIONS,POST,GET,PUT,DELETE",
        })
    )
a
Thanks @rp_st , what does the handler in
return handler(event);
refer to?
Is it the same one that is exported? Won't it cause an infinite recursion?
r
oh sorry. you can ignore that
updated the code
now if you call anything like
/auth/abc
, basically any path that we don't support, it will return Hello
which you can use as a healtcheck
if you want, you can add a check for the path and then return the Hello, else a 404
a
Oh nice, thanks
25 Views