Hi team, super excited to test out supertokens. H...
# support-questions-legacy
n
Hi team, super excited to test out supertokens. However I'm having issues at the first hurdle. It seems that supertokens middleware is not generating the auth routes on nestjs (express) as it promises to do. Minimal repro code:
Copy code
import { Logger } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import { init } from "supertokens-node";
import { middleware } from "supertokens-node/lib/build/framework/express";
import Session from "supertokens-node/recipe/session";

import { AppModule } from "./app/app.module";

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const port = process.env.PORT || 3000;
  await app.listen(port);

  app.use(middleware());

  init({
    framework: "express",
    appInfo: {
      appName: "codestacks",
      apiDomain: "http://localhost:3000",
      websiteDomain: "http://localhost:4200",
    },
    supertokens: {
      connectionURI: "http://localhost:3567",
    },
    recipeList: [Session.init()],
  });

  Logger.log(`🚀 Application is running on: http://localhost:${port}`);
}

bootstrap();
The expectation is now that
http://localhost:3000/auth/signup
etc.. will now be created. However when using postman or curl to POST the routes are 404. Similarly, if you point the supertokens FE at this api domain it is similarly returning 404 in the network request coming from the supertokens UI. FYI same thing happens if I follow the actual nest setup with in the guide with an AuthModule - however I suspect that should not make a difference to the minimal repro code above, its just "nestifying" the middleware, it should work the same in both scenarios AFAIK.
r
hey @nickm91.
I see that you have only added session.init in the recipe list
this only exposes the refresh and signout API routes
you also maybe want to add emailpassword.init or another auth recipe which will expose the related sign in / sign up routes
n
Thanks for starting the thread! Here is an adjusted snippet:
Copy code
import { Logger } from "@nestjs/common";
import { NestFactory } from "@nestjs/core";
import supertokens, { init } from "supertokens-node";
import { middleware } from "supertokens-node/framework/express";
import EmailPassword from "supertokens-node/recipe/emailpassword";
import Session from "supertokens-node/recipe/session";

import { AppModule } from "./app/app.module";

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const port = process.env.PORT || 3000;
  await app.listen(port);

  app.use(middleware());

  init({
    framework: "express",
    appInfo: {
      appName: "app",
      apiDomain: "http://localhost:3000",
      websiteDomain: "http://localhost:4200",
      apiBasePath: "/auth",
      websiteBasePath: "/auth",
    },
    supertokens: {
      connectionURI: "http://localhost:3567",
    },
    recipeList: [Session.init(), EmailPassword.init()],
  });

  app.enableCors({
    origin: "http://localhost:4200",
    allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
    credentials: true,
  });

  Logger.log(`🚀 Application is running on: http://localhost:${port}`);
}

bootstrap();
Still the no auth routes are present, either on the base localhost path or the /auth path
r
can you enable backend debug logs and then send a query? What are the log output?
see the troubleshooting section on how to enable backend logs
n
Nothing in the logs that stands out
r
well.. this means the supertokens middleware is not being called at all
which probably means that
app.use(middleware());
is not correctly done
im quite sure that our guide for nestjs works cause we have had several people implement it - can you double check if you followed things correctly please?
n
Ok copy the code line for line from the guide it is generating the routes for nest ✅
But now I am getting the error
Error: No SuperTokens core available to query
http://localhost:3567/hello returns 200 "Hello"
Running on docker inside mac
Ahh reading through the discord thread, uri
http://auth:3567
works as per docker compose network discoverability
r
yup!!
3 Views