Angular deploy-url switcher issues

I want to deploy my spring-boot webapp with angular-frontend to tomact server. I am creating angular app with angular-cli and the following commandod

ng build --deploy-url /mywebapp/

      

The app works, but the following problems still exist:

  • Every time I have to manually change the base href tag to <base href="/mywebapp/">

    . Why isn't this done automatically during the build process?
  • All paths to static assets in the "assets" directory must also be manually changed to "/ mywebapp / assets" (ie <img src="/mywebapp/assets/logo.png">

    )
  • Refreshing browser links to routers urls (subfolders) no longer work. (i.e. angular navigation to http: // localhost: 8080 / mywebapp / feature1 , but if I want to update the same url in the browser it doesn't work.just update the root url http: // localhost: 8080 / mywebapp / )
0


source to share


1 answer


Whenever you build

build it with

ng build --base-href .

      

This will help solve problems # 1 and # 2 ur

For task 3



This SO post will work angular html5mode in tomcat apache 8.5.4 gives 404 on update page

  • add /opt/tomcat/conf/context.xml

<!-- REWRITE VALVE --> <Valve className="org.apache.catalina.valves.rewrite.RewriteValve" /> <!-- // -->

  1. add rewite.config file in special project WEB-INF folder with content below eg. on / opt / tomcat / webapps / projectName / WEB-INF / rewrite.config RewriteCond %{REQUEST_URI} !^.*\.(bmp|css|gif|htc|html?|ico|jpe?g|js|pdf|png|swf|txt|xml|svg|eot|woff|woff2|ttf|map)$ RewriteRule ^(.*)$ /index.html [L]

    What it does for each of these routes it redirects to index.html
+1


source







All Articles