Hi, I am new to supertoken and started using nextj...
# support-questions-legacy
j
Hi, I am new to supertoken and started using nextjs a few weeks back. When I try to implement supertokens in nextjs based on the guide I am getting the following error. Any help?
Copy code
[Nest] 21310  - 05/26/2022, 5:25:10 PM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the SupertokensService (?). Please make sure that the argument ConfigInjectionToken at index [0] is available in the AuthModule context.
r
hey @Jamm
j
yes hi
r
@porcellus is the nestjs expert! i think he can help out
j
Thanks will wait for him
p
hi
you wrote nextjs, but the error seems to be from nestjs 🙂
can you show me
auth.module.ts
?
j
lol sorry. nextjs is my frontend it was a typo
Copy code
import {
  MiddlewareConsumer,
  Module,
  NestModule,
  DynamicModule,
} from '@nestjs/common';

import { AuthMiddleware } from './auth.middleware';
import { ConfigInjectionToken, AuthModuleConfig } from './config.interface';
import { SupertokensService } from './supertokens/supertokens.service';

@Module({
  imports: [
    AuthModule.forRoot({
      connectionURI: 'http://localhost:3567',
      appInfo: {
        appName: 'Alchemist',
        apiDomain: 'http://localhost:3000',
        websiteDomain: 'http://localhost:3000',
        apiBasePath: '/api/auth',
        websiteBasePath: '/auth',
      },
    }),
  ],
  providers: [SupertokensService],
  exports: [],
  controllers: [],
})
export class AuthModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(AuthMiddleware).forRoutes('*');
  }

  static forRoot({
    connectionURI,
    apiKey,
    appInfo,
  }: AuthModuleConfig): DynamicModule {
    return {
      providers: [
        {
          useValue: {
            appInfo,
            connectionURI,
            apiKey,
          },
          provide: ConfigInjectionToken,
        },
      ],
      exports: [],
      imports: [],
      module: AuthModule,
    };
  }
}
p
that's what I figured 🙂
oh, the
AuthModule
should not import itself, it should be imported by the
AppModule
j
Ohh my bad 😅
Fixed it now thanks
p
happy to help 🙂
2 Views