diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 619bc4b..da29a51 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -50,7 +50,7 @@ export class AuthController { const { access_token } = await this.authService.login(user); - res.cookie('accecdss_token', access_token, { + res.cookie('access_token', access_token, { httpOnly: true, secure: process.env.COOKIE_SECURE === 'true', sameSite: (process.env.COOKIE_SAME_SITE as 'strict' | 'lax' | 'none') || 'strict', diff --git a/src/auth/auth.module.ts b/src/auth/auth.module.ts index 14ae022..7b5026d 100644 --- a/src/auth/auth.module.ts +++ b/src/auth/auth.module.ts @@ -13,7 +13,7 @@ import * as cookieParser from 'cookie-parser'; TypeOrmModule.forFeature([User]), PassportModule, JwtModule.register({ - secret: process.env.JWT_SECRET || 'your-secret-key', + secret: process.env.JWT_SECRET, signOptions: { expiresIn: '1h' }, }), ], diff --git a/src/auth/jwt.strategy.ts b/src/auth/jwt.strategy.ts index 6cdc40a..a52891b 100644 --- a/src/auth/jwt.strategy.ts +++ b/src/auth/jwt.strategy.ts @@ -14,7 +14,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) { }, ]), ignoreExpiration: false, - secretOrKey: process.env.JWT_SECRET || 'your-secret-key', + secretOrKey: process.env.JWT_SECRET, }); } @@ -22,7 +22,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) { return { userId: payload.sub, username: payload.username, - login: payload.username // Добавляем для совместимости + login: payload.username }; } } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 7cc2c6e..de8c6f6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,7 @@ async function bootstrap() { // Настройка CORS app.enableCors({ - origin: [process.env.FRONTEND_URL, "http://dev.msf.enode"], //|| 'http://192.168.2.39:5173', // Точный URL фронтенда + origin: [process.env.FRONTEND_URL, "http://dev.msf.enode"], credentials: true, methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS', allowedHeaders: 'Content-Type, Authorization, X-Requested-With',