maybe we're doing this wrong but is there a sane w...
# support-questions-legacy
z
maybe we're doing this wrong but is there a sane way to authenticate just from the backend (supertokens-node) without using the frontend js-sdk and just with the session recipe? every time we update to the latest versions something breaks... -
supertokens-node@13.4.1
to
14.1.1
- Docker Image
supertokens-postgresql@4.6
to
5.0
, we're currently hitting a GET endpoint that's only available during development which just simply calls this code so that we get a session and move on
Copy code
js
const session = await Session.createNewSession(ctx.req, ctx.res, user.id);
recipe code:
Copy code
ts
import Session from 'supertokens-node/recipe/session/index.js';
import { UnauthenticatedError, UnauthorizedError } from '@/errors/index.js';

export const SessionRecipe = Session.init({
  errorHandlers: {
    onTokenTheftDetected: (sessionHandle, userId, req, res) => {
      throw new UnauthorizedError('Token theft detected.', {
        sessionHandle,
        userId,
      });
    },
    onUnauthorised: (_, req, res) => {
      throw new UnauthenticatedError();
    },
  },
  // https://supertokens.io/docs/session/advanced-customizations/apis-override/usage
  override: {
    apis: (originalImplementation) => ({
      ...originalImplementation,
      // https://supertokens.io/docs/session/advanced-customizations/apis-override/disabling
      signOutPOST: undefined,
    }),
  },
});
stacktrace is:
Copy code
ts
Error: SuperTokens core threw an error for a POST request to path: '/recipe/session' with status code: 500 and message: Internal Error\n\n    at Querier.<anonymous> (/usr/src/app/node_modules/.pnpm/supertokens-node@14.1.1/node_modules/supertokens-node/lib/build/querier.js:260:31)\n    at Generator.throw (<anonymous>)\n    at rejected (/usr/src/app/node_modules/.pnpm/supertokens-node@14.1.1/node_modules/supertokens-node/lib/build/querier.js:22:43)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n
7 Views