title: GET http://localhost:8000/users/login 404 (Not Found)
body: <p>I am using passport Js for authentication.</p>
  
  <p>I have tested the API through Postman and everything works fine. However, when I actually try to login using my signin page I am getting the following error :</p>
  
  <p>GET <a href="http://localhost:8000/users/login" rel="nofollow noreferrer">http://localhost:8000/users/login</a> 404 (Not Found)</p>
  
  <pre><code>//signin.html
  
  &lt;form class="px-4 py-3" [formGroup]="signinForm"&gt;
    &lt;div class="input-group mb-3"&gt;
      &lt;div class="input-group-prepend"&gt;
        &lt;span class="input-group-text"&gt;@&lt;/span&gt;
      &lt;/div&gt;
      &lt;input
        formControlName="username"
        type="text"
        class="form-control"
        placeholder="Email Address"
      /&gt;
    &lt;/div&gt;
    &lt;div class="input-group mb-3"&gt;
      &lt;div class="input-group-prepend"&gt;
        &lt;span class="input-group-text"&gt;#&lt;/span&gt;
      &lt;/div&gt;
      &lt;input
        formControlName="password"
        type="password"
        class="form-control"
        placeholder="Password"
      /&gt;
    &lt;/div&gt;
    &lt;button type="button" class="btn btn-primary" (click)="login()"&gt;
      Sign In
    &lt;/button&gt;
    &lt;p style="color: white;margin-bottom: 0;margin-top: 2%;"&gt;
      New around here? &lt;a [routerLink]="['/users/new']"&gt;Sign Up&lt;/a&gt;
    &lt;/p&gt;
  &lt;/form&gt;
  
  //signin.component.ts
  
  export class SigninComponent {
  signinForm: FormGroup = new FormGroup({
  username: new FormControl(null, [Validators.email, 
  Validators.required]),
  password: new FormControl(null, Validators.required)
  });
  constructor(private apiService: ApiserviceService, private router: 
  Router) {}
  
  login() {
  if (!this.signinForm.valid) {
    console.log("Form Invalid");
    window.alert("Please Fill All Fields");
    return;
  }
  console.log(JSON.stringify(this.signinForm.value));
  this.apiService
    .login(JSON.stringify(this.signinForm.value))
    .subscribe(data =&gt; {
      console.log(data);
    });
  }
  }
  
  //apiservice.service.ts
  
  login(body: any) {
  return this.http.post("http://localhost:8000/users/login", body, {
    observe: "body"
  });
  }
  
  //userRoutes.js
  
  router.post(
  "/users/login",
  passport.authenticate("local", {
  successRedirect: "/questions",
  failureRedirect: "/signin"
  }),
  function(req, res) {}
  );
  
  //app-routing.module.ts
  
  const routes: Routes = [
  { path: "question/:id/answer/new", component: AnswerComponent },
  { path: "question/:qId/answer/:aId/edit", component: 
  EditanswerComponent }, 
  { path: "question/:id", component: AnswerComponent },
  { path: "questions/new", component: AskComponent },
  { path: "users/new", component: SignupComponent },
  { path: "signin", component: SigninComponent },
  { path: "questions", component: QuestionsComponent },
  { path: "answer", component: AnswerComponent },
  { path: "", redirectTo: "/users/new", pathMatch: "full" },
  { path: "**", component: PagenotfoundComponent }
  ];
  </code></pre>
  
  <p>GET <a href="http://localhost:8000/users/login" rel="nofollow noreferrer">http://localhost:8000/users/login</a> 404 (Not Found)</p>