Redirect with Angular 8 not working

Hey!

I have an Angular SPA that I would like to deploy with Netlify. My site goes live like a charm but when I hit refresh on any page it redirects to Page Not Found. I have read the documentation where it claimed I should use redirects since I use Angular Routing in my app.

So I have created a _redirects file in my src folder with /* /index.html 200 in it that should navigate all route to the index file so the Angular Router could handle the rest, and I added "src/_redirects" to my angular.json/assets array.

But when I check to Deploy Summary I see that No redirect rules processed. Am I missing something?

Thank you in advance!

Hi, @Hordon13, and welcome to our Netlify community site. I was going to recommend that exact solution:

Seeing as you have already done this, it might help to examine the build itself. Would you please send us a link to the site at Netlify? (Meaning a URL starting with https://app.netlify.com/sites/?)

My best guess is that the file isn’t being copied by Angular to dist and examining the build itself would be the first step in troubleshooting why not.

So what is the solution? I am having this exact issue and i have already added the steps mentioned above. Can you please help?

It is likely your redirects file is incorrect or did not end up in the correct location. Could you link us to your site, please?

@fool Sure its: https://hardcore-roentgen-37505f.netlify.com

Please let me know if you need anything else.

Thanks, that is exactly what I was looking for. That site has no redirects applied, so no surprise they don’t work :slight_smile: Please make sure your _redirects file ends up next to index.html after building so we see and deploy it !

I don’t think your site generator needs to know about it - you just need to deploy that file next to index.html to “activate” it.

If anyone is still looking for a fix for this, this is what worked for me: Angular routing not working on Netlify on page refresh - Stack Overflow

1 Like

i still have this issue can anyone help me ?

hi there, have you checked the solution mentioned above?