Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

276
Views
Error entre la parte de autenticación de nginx y nestjs

Intento usar un backend NestJS con un proxy inverso Nginx. He codificado una parte de autenticación en mi backend de NestJS.

Mi problema es que cuando utilicé mi frontend/backend en modo local, todo está bien. Cuando lo uso a través de Nginx, siempre obtengo un error 401. Creo que se debe a LocalStrategy en NestJS

Aquí está la parte en el archivo local.strategy.ts

 import { Strategy } from 'passport-local'; import { PassportStrategy } from '@nestjs/passport'; import { Injectable, UnauthorizedException } from '@nestjs/common'; import { AuthService } from '../auth.service'; @Injectable() export class LocalStrategy extends PassportStrategy(Strategy) { constructor(private authService: AuthService) { super({ usernameField: 'userLogin', passwordField: 'userPassword', }); } async validate(userLogin: string, userPassword: string): Promise<any> { const user = await this.authService.validateUser(userLogin, userPassword); if (!user) { throw new UnauthorizedException(); } return user; } }

Aquí está la parte en el archivo app.controller.ts

 @Public() @UseGuards(LocalAuthGuard) @Post('auth/login') async login(@Request() req) { return this.authService.login(req.user); }

Pero no sé cómo cambiarlo. Si alguien tiene un ejemplo, sería genial. Gracias por adelantado.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

He probado con curl localmente en el servidor (sin nginx). Vi mi error (acceso a mysql para probar al usuario), no se debió a la configuración de nginx.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!