Monday, 8 July 2019

how to configure the server part or frontend to avoid the error not found 404 when I run ng build

I ask this question because I'm not sure if from the frontend or backend is the solution to my problem, I hope you can help me.

Basically, I have the problem that when reloading the page in a different route from the start "/", I get the error "not found 404", I have seen some possible solutions such as include a "hash" but for SEO issues I can not do it. I have also seen that there are configurations to solve this problem, but these configurations are in apache servers or in ISS.

 my application works fine while using angular-cli with ng serve, but when I run

ng build --prod --base-href=./ and --deploy-url=./

the routes do not work when I reload the page.

for example:

http://localhost/my_folder_compilated/programa/detalle-programa/5cf7d27faa8e180017211754    --> 404 not found!

I need to deploy it on a Heroku server or in its absence any that works on nodejs.

How can I solve this problem?

// this is the route that I have in my app.routing.ts
{path: 'programa/detalle-programa/:programaId', component: 
DetalleProgramaComponent},
{path: '**', component: NotFoundComponent}

note: I think the solution is in the backend. I'm using nodejs, but I can not fix it.



from how to configure the server part or frontend to avoid the error not found 404 when I run ng build

No comments:

Post a Comment