Skip to content

ng-build not able serve the app in tomcat, throwing 404 error #1361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hareeshav opened this issue Jul 17, 2016 · 3 comments
Closed

ng-build not able serve the app in tomcat, throwing 404 error #1361

hareeshav opened this issue Jul 17, 2016 · 3 comments

Comments

@hareeshav
Copy link

Hi,
i'm able to serve the files with http server, ng serve. But I want to deploy to tomcat server, I ran the command ng build -prod and got the dist folder created. I need to place the dist folder content inside project folder of webapps. Let say, sampleapp is my project folder, I copied all the contents ,generated in dist folder to sampleapp folder. When i access the application in getting lot of 404 error(
http://localhost:8080/vendor/systemjs/dist/system.src.js). It seems Angular is looking in root direectory. How can i customize the build to read it from my project directory?
like
http://localhost:8080/sampleapp/vendor/systemjs/dist/system.src.js
I tried editing the index.html tag , and then built. No luck

Which file I have to look out for the ng-build command. Please help me out in finding the solution

@francisoud
Copy link

@hareeshav I got the same error.
My static webapp (angular2) is deploy in tomcat under http://localhost:8080/myapp

You need to change in index.html
<base href="/">
to
<base href=".">

All angular.io documentation assume that you will deploy your apps under ROOT http://localhost:8080/ (usually the case with virtual host but not the commons case in tomcat / java world)

@wardbell It would be nice if a warning could be added in the following docs pages ;)
https://angular.io/docs/ts/latest/tutorial/toh-pt5.html#!#add-routing
https://angular.io/docs/ts/latest/guide/router.html#!#base-href

@filipesilva
Copy link
Contributor

This deployment issue isn't specific to the CLI so I am closing. But I'd like to say that we have an issue open to add the base tag override #1064

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants