Reputation: 1197
I am new to Angular2 Wep app development.
I created one Angular2 app with use of angular-cli, now i want to deploy this app to my tomcat server.
I gave ng build and it create the dist folder for deployment. I copied all files inside the dist folder and create one folder inside the Tomcat webapps folder like somename and paste all files inside this somename folder. And i changed the index.html base href as /somename.
<base href="/somename">
if i run the app from server like localhost:9000/somename. it gives the error in console like file not error.
How can i solve the issue.
please help me, thanks in advance.
Upvotes: 1
Views: 2867
Reputation: 1504
Try setting base href as one of the following:
<base href="./">
: This usually works well for starter packs, or beginner projects that do not have/use Angular Routers. It basically sets the base
as whichever directory it is served from.
<base href="/somename/>
(Note the ending /
):
This worked well for me on IIS 8.5 -- more details here.
Also, on a related note, a minor piece of advise would be to use ng build --base-href your-new-base-href
command instead of manually editing index.html
everytime you build your app.
Upvotes: 3
Reputation: 614
Try to build app like
ng build --base-href /myApp/
or
<base href="/myApp/">
Your dist folder content should be copied to "myApp" folder. Run the app from tomcat server like localhost:8080/myApp/
Upvotes: 1