fix(auth): centralize JWT secret with registerAsync to ensure consistent signing and verification

This commit is contained in:
parsa aghaei committed 2026-08-16 15:11:05 +03:30
1 parent 1a21c4c642
commit 0c32985ce2
3 files changed
+22 -14

No files matched your search

+6 -8
View File
@@ -5,19 +5,17 @@ import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtStrategy } from './jwt.strategy';
import { UsersModule } from '../users/users.module';
const JWT_SECRET =
process.env.JWT_ACCESS_SECRET ||
process.env.JWT_SECRET ||
'canina_jwt_fallback_secret_32_characters_minimum_len_2026';
import { getJwtSecret } from './auth.constants';
@Module({
imports: [
UsersModule,
PassportModule,
JwtModule.register({
secret: JWT_SECRET,
signOptions: { expiresIn: '7d' },
JwtModule.registerAsync({
useFactory: () => ({
secret: getJwtSecret(),
signOptions: { expiresIn: '7d' },
}),
}),
],
controllers: [AuthController],