Deploying to PASOE

Building for a context path

It is recommended that the Angular web application is deployed under a context path. For example, assuming the application name MyApplication and the context path /myapplication, the resulting URL would be https://my-application-domain.com/static/myapplication.

To support this, the web application must be built using the appropriate base-href parameter value.

In your project root, run the following command:

ng build --prod --base-href /static/myapplication/

The context path must be enclosed in leading and trailing “/” characters.

Deploying the build to a PASOE

Assuming a custom output directory has not been provided, your build should now be located at <project_root>/dist/myapplication.

Copy the myapplication directory at the following location:

<pasoe_root>/webapps/ROOT/static/myapplication

Angular handles routing directly on the client. When a change in browser location is detected, Angular will try to match certain parts of the URL to Angular routes. When the application is hosted on a PASOE instance, this will work out of the box as long as navigation is performed after the Angular application was loaded.

However, if we attempt to open a specific Angular route directly (for example by bookmarking a page), the PASOE will return a 404 NOT FOUND error. This is because when using a deep link, the Angular application has not yet been loaded and thus is not handling the matching of URL segments to Angular routes.

To support this, the following changes need to be made to your PASOE configuration:

 

<pasoe_root>/conf/server.xml

Find the following element:

<Engine name="Catalina" defaultHost="localhost" jvmRoute="${psc.as.alias}" startStopThreads="0" >

Add the following child to this element:

<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />

 

<pasoe_root>/conf/Catalina/localhost/rewrite.config

Please create this file if it does not already exist.

Add the following lines:

The above URL rewrite rule will ensure that the Angular application has been loaded before the URL segments are parsed.

Replace myapplication with the name of the directory under which the contents of your application build reside.

Finally, restart your PASOE.