the_b1ackfox
asked on
Deploying Angular CLI app
I'm having trouble with some odd routing behavior when I build my angular app in preparation for deployment. When I run the app locally using 'ng serve', navigation works just fine and everything seems to be ready for deployment. However after I run 'ng build --prod' and the dist folder is generated, if I launch the index.html navigation is broken in the following ways:
If I refresh the page, it fails to load (resulting in 404)
If I attempt to navigate to a page that uses a different component than the landing page it fails to load (404)
I have tried these suggested solutions:
Change the base href in index.html to <base href = "./">
Change AppModule providers to include {provide: LocationStrategy, useClass: HashLocationStrategy}
Change App.Routing to include RouterModule.forRoot(route s, {useHash: true})
If I refresh the page, it fails to load (resulting in 404)
If I attempt to navigate to a page that uses a different component than the landing page it fails to load (404)
I have tried these suggested solutions:
Change the base href in index.html to <base href = "./">
Change AppModule providers to include {provide: LocationStrategy, useClass: HashLocationStrategy}
Change App.Routing to include RouterModule.forRoot(route
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If was the first time we had tried to do this. Checking into the console we found a bunch or errors which led us to realize that we weren't deploying correctly. Ended up changing the base href and deploying via AWS S3
ASKER
Thank you for the assist Julian!!
You are welcome.
Do you still require assistance with this question? If so post back here, otherwise please can you close the question.