mike idowu

mike idowu

  • 1.2k
  • 437
  • 62.2k

Angular - Error 404 in Angular User Signup activation using Laravel

Jul 1 2021 7:30 AM

I have a application with Angular-12 as frontend and Laravel-8 as backend.

After user have successfully created account, it sends notification to activate account. This is done from the backend (Laravel) to the Frontend (Angular)

Laravel Notification:

     public function toMail($notifiable)
     {
          return (new MailMessage)
          ->subject('Confirm your account')
          ->action('Confirm Account', url('https://nairobischool.com/auth/signup-activate?token='.$notifiable->activation_token));
      }

Angular Routes:

app-routing.module
    const routes: Routes = [
      {path: '', redirectTo: 'home', pathMatch: 'full'}
      {path: 'auth', loadChildren: () => import('./features/auth/auth.module').then(m => m.AuthModule)}
    ];

auth-routing.module:

    const routes: Routes = [
      {path: '',
      component: LoginComponent,
      children: [
      {
        path: '',
        component: AuthComponent
      },
      {
        path: 'signup-activate',
        component: SignupConfirmComponent
     }
    ]}];

    @NgModule({
      imports: [RouterModule.forChild(routes)],
      exports: [RouterModule]
    })
    export class AuthRoutingModule { }

But the the user tries to access it, the error comes up:

> 404 Not Found

The page really exist.

When I added #, it takes the user straight to the home page:

     function toMail($notifiable)
     {
        return (new MailMessage)
        ->subject('Confirm your account')
        ->action('Confirm Account', 
        url('https://nairobischool.com/#/auth/signup-activate?token='.$notifiable->activation_token));
      }

How do I resolve it?

Thanks


Answers (3)