Change CUBA "development" mode to "production" mode to get rid of auto prepended "app-portal" in URL

Hi there,

We have a portal module, so the URL for the portal app needs an “app-portal” in the url, e.g localhost:8080/app-portal.

We also have a domain name, which hides the “app-portal” from the URL in the browser by website redirect configuration on DNS server. For example, say our domain is When I go to, it’ll show “” in the browser but internally it is ultimately redirected to our local tomcat server: “192.168.1.xx:8080/app-portal”.

Right now, as we’re still in developing mode, i.e., every request and resource URL need “app-portal” explicitly specified, e.g. AJAX →



<script src="/app-portal/resources/............"></script>

. But now, with the domain name, we don’t need the app-portal anymore as the domain already includes it, so the new resource URL should be

<script src="/resources/.........."></script>


If we do that by removing “/app-portal” from

<script src="/app-portal/resources/............"></script>

, the resource retrieving works. However, in our portal-spring-security.xml we have a form-login tag, to allow users log in. The “default-target-url” attribute is set to “/bo/bo”. In this “development” mode, the portal app URL is “localhost:8080/app-portal”, and it resolves to “localhost:8080/app-portal/bo/bo” by prepending “app-portal” to “/bo/bo”.
However, in production, when I am on “” and log in, the URL ultimately ends up at tomcat server becomes “192.168.1.xx:8080/app-portal/app-portal/bo/bo” after login. Notice the double app-portal.

Is there a way in CUBA platform to disable this automatic prepending of “app-portal”, most preferably throughout the entire system? I was thinking there might be some global configuration flag to change CUBA from “development” to “production” mode when deploy to Tomcat, or I should configure DNS differently to make the Cuba portal app working?

If the solution needs a nginx kind of reverse proxy sitting in front of Tomcat, we can also do that.

Thank you,

Here is the login form tag:

<form-login always-use-default-target="true" 



First of all, deploy your portal application as ROOT application to tomcat. It means that you should rename tomcat/webapps/app-portal folder ro tomcat/webapps/ROOT so your application will be deployed to /.

After that set cuba.webContextName in tomcat/conf/app-portal/

cuba.webContextName = /

And your portal will be accessible at http://domain.domain-zone/

Do not change the application code for this / deployment, just tune app settings. That should be enough.

1 Like

Also, check this manual page: Using Tomcat in Production - CUBA Platform. Developer’s Manual

1 Like

Hi Yuriy,

What you suggested works great!

I followed your instructions and read carefully the manual page you pointed to. The portal app is deployed into Tomcat ROOT. The conf path need to make tiny change from:

cuba.webContextName in tomcat/conf/app-portal/


cuba.webContextName in tomcat/conf/ROOT/

in the code I need to remove “/app-portal” from all the request to server. Then the app is accessible correctly.

Thank you very much for the great help,