Deploying the full-stack-project-template under custom context path

We are currently trying to migrate our cosmo a12 applications to be closer to the full-stack-project-template and run into the problem that our applications may run under a custom context path e.g.
https://some-application/{custom-context-path}/ .
Is there a clean way to configure this using a12 functionality?

Our current solution is to write the context-path the application is deployed to into the index.html and create the ConnectorLocator instance with the adapted api URL in our appsetup.ts.
This feels very hacky and is very error prone as we never know when the instance of the ConnectorLocator is recreated or even if we only have one instance where the api url is set.

Hi @stefan-sparse-array,
Currently, we are using spring configuration to get different context paths.
As you mentioned that your project is closer to the full-stack-project-template so I think you can change the configuration by yourself.

With the server side: you can update refer to this property mgmtp.a12.dataservices.server.context-path

and update the webpack configuration file with your custom context on the client side.

Also, you can consider with property pathRewrite here: http-proxy-middleware/recipes/pathRewrite.md at master · chimurai/http-proxy-middleware · GitHub

Hey @anh-free-mist
thanks for your fast response.

The part with the dataservices is true. I was able to configure the context path in the backend / data-services and even to configure uaa using the self-configuration.

The only problem i’m facing right now is that the client unfortunately still needs to know the custom context path and can not retrieve it from the backend, as the path is not known in the client yet.
(I think the uaa self configuration needs an initial server url to fetch)

On production we use an nginx based deployment like in the full stack template so configuring webpack (i guess you meant to proxy the requests) does not work for us.

As our environments are managed by a global traefik instance i think a path rewrite is not possible and would still have the problem that for that the client needs to know the current context-path.

Right now i can not think about a solution how to get the context-path into the client without writing it into some file during compile time.
But i think the data-services and uaa configuration make it a lot easier already.

If you have any idea how to solve the client part let me know, else thanks a lot for your help :heart:

Moin @stefan-sparse-array
there’s no out of the box solution in A12 which covers your use case.

If you want to configure the context path differently from what is implemented in the Project Template, then you have following options:

  • Configure the custom context path in the deployment configuration
  • Define a REST endpoint, providing all of the base urls, which you fetch first to use for the client configuration (this is what another A12 project is doing)
  • Deploy client on the same server and use relative path