Angular Router Get 404 Bug?

My problem is that every time I upload my link. Example: " https://www.example.com/ " it will be redirected to " https://www.example.com/design-brief ", since I configured it in my routing.ts. But when I use the link " https://www.example.com/design-brief " and enter in my address bar, it will show an error in the console log. "GET https://www.example.com/design-brief 404 ()"

const APP_ROUTES: Routes = [
{ path: 'design-brief', component: DesignBriefComponent },
{ path: 'design-evaluation', component: DesignEvaluationComponent },
{ path: '', redirectTo: '/design-brief', pathMatch: 'full' },
{ path: "**",redirectTo:"/design-brief" } ];

Here is my code in my routing.ts

+1
source share
3 answers

. , .

2 :

  • -, index.html , 404 - , Angular .

  • Strategy Hash, . , URL- , , .

+2

**, ** pathMatch 'full':

const APP_ROUTES: Routes = [
{ path: 'design-brief', component: DesignBriefComponent },
{ path: 'design-evaluation', component: DesignEvaluationComponent },
{ path: "**",redirectTo:"design-brief",pathMatch: 'full' } ];

(/) -

0

I solved this using the Hash placement strategy. Add the following code to the @ngModule import part and the prefix of your entire C # hyperlink and also link to the offecial link for information

RouterModule.forRoot(
   appRoutes,{ useHash: true }
)
0
source

Source: https://habr.com/ru/post/1684149/


All Articles