Skip to main content

Getting related application route during buildtime



  • Kai de Haan

    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?

  • Chad Carlson

    Hi there! Yes, during the build phase PLATFORM_ROUTES is not available. This helps keep builds isolated and environment-independent.

    In my experience, there are two ways around the limitation.

    1. Delay the build. As you can see from our Next.js + Drupal template, you can delay the build to the post_deploy hook when the backend application and PLATFORM_ROUTES is 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.
    2. Use subdirectory multi-app routes. If during build the Vue.js is not actually pulling content from the backend application, but merely needs a URL to successfully build, you can instead define each application in routes.yaml to 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 /api rather 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 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.