Getting related application route during buildtime
Kai de Haan
I’m trying to build a VueJS application that needs some environment variables compiled into the code. Mainly its own Application URL and the URL to an accompanying PHP backend.
I could try to parse the PLATFORM_ROUTES env, but it seems rather cumbersome, as I don’t really have a key to identify the correct route.
The setup uses a multi-app configuration via submodules
0
Comments
Looks like PLATFORM_ROUTES and _RELATIONS are not available in the build process, so it seems there are no ways to get the URL of another application?
Hi there! Yes, during the build phase
PLATFORM_ROUTESis not available. This helps keep builds isolated and environment-independent.In my experience, there are two ways around the limitation.
post_deployhook when the backend application andPLATFORM_ROUTESis available to define the backend location for the current environment. Note it will be necessary to define a mount for the Vue.js build directory in this case, since post-build the file system is read-only.routes.yamlto serve from a subdirectory rather than a subdomain. For example, the Vue.js from{default}and the PHP app from{default}/api. That way, if Vue.js allows, your backend config can simply be/apirather than the full backend URL.That said, I’ve often found that a combination of both of these is necessary to do multi-app correctly on Platform.sh. Take a look at the template I’ve linked above and let us know if you have more questions.
Please sign in to leave a comment.