1

I have a Web Site (Angular 16). That's deploy in IIS 10 (HTTPS port 443 with a Certificate)

I have ARR enabled, and on my web site tengo a rewrite ruler.

My back-end is in Node.js. It's running in the same serv but in other port (3000), also with HTTPS and a Certificate.

No problem when call back-end para method POST. Is OK no problem.

The problem is when the web call a PUT method. Never reaches my back-end. I know that because I have the next code beginning my server.js (archivo principal in my back-end):

app.use((req, res, next) => {
  console.log(`Ruta recibida: ${req.url}`);
  next();
});

Never reaches the PUT to my back-end because not print nada.

In the console Chrome. Say that: PUT rutacompleta 403 (Forbidden)

When I call the same PUT method with POSTMAN no problem, works OK. But the problem is when I use Chrome, I can't.

service code:

InactivarUsuario(
  usuario: Usuario,
  token: string
): Observable<HttpResponse<any>> {
  const url = `${configGlobal.urlApiTerrenos}usuarios/actualizaestadovigenciausuario`;
  const headers = new HttpHeaders({
    Authorization: `Bearer ${token}`, // Añade el token en el encabezado de autorización
  });
  return this.http.put<any>(
    url,
    { usuario },
    { headers, observe: 'response' }
  );
}

component.ts code:

if (this.token) {
  this.usuarioService
    .InactivarUsuario(usuario, this.token)
    .pipe(
      catchError((error: HttpErrorResponse) => {
        if (error.status === 0) {
          this.messageConfirmationModal =
            'Problemas de Red, por favor, comunicarse con personal de TI';
        }
        return of(null);
      })
    )
    .subscribe((data) => {
      if (data && data.status === 200) {
        if (usuario.vigencia === 'A') {
          this.toastr.success('El usuario ha sido activado con éxito.'); // Muestra el toast
        } else {
          this.toastr.success('El usuario ha sido inactivado con éxito.'); // Muestra el toast
        }

        this.buscarUsuarios();
      }
    });
}
13
  • please share the service method and component code used to make this API call Commented Nov 26, 2024 at 0:22
  • @angular service method: InactivarUsuario(usuario: Usuario, token: string): Observable<HttpResponse<any>>{ const url = ${configGlobal.urlApiTerrenos}usuarios/actualizaestadovigenciausuario; const headers = new HttpHeaders({ 'Authorization': Bearer ${token} // Añade el token en el encabezado de autorización }); return this.http.put<any>(url, { usuario } ,{headers, observe:'response'}); } Commented Nov 26, 2024 at 0:28
  • component code also, please update on the question, the code which uses this service method Commented Nov 26, 2024 at 0:29
  • ok. Component code ok the update in the question Commented Nov 26, 2024 at 0:36
  • your code looks fine stackblitz so you are either not calling the method, check your chrome debugger network tab and check if the API is called, else validate the URL in the network tab is correct. Commented Nov 26, 2024 at 0:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.