LoginSignup
0
0

More than 1 year has passed since last update.

[NestJS] 認証でハマった

Last updated at Posted at 2022-06-10

概要

公式のドキュメントを見て学習していたら、エラーがでて困った。

エラー内容

[Nest] 3551  - 06/10/2022, 6:41:52 AM   ERROR [ExceptionsHandler] Unknown authentication strategy "local"
Error: Unknown authentication strategy "local"
・・・

対処

・ app.module.tsのimportsにAuthModuleを追加する。

app.module.ts
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UsersModule } from './users/users.module';
import { AuthModule } from './auth/auth.module';

@Module({
  imports: [
    UsersModule,
+   AuthModule
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

・ users.service.tsのexportsにUsersServiceを追加する。(ドキュメントの見落とし。。。)

users.module.ts
import { Module } from '@nestjs/common';
import { UsersService } from './users.service';

@Module({
  providers: [UsersService],
+  exports: [UsersService],
})
export class UsersModule {}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0