How to include Phoenix content in a Rails app?

I am in charge of a large Rails application and would like to use Phoenix for some of the new features.

This means that we often have to embed pages generated by Phoenix in the pages generated by Rails.

I am wondering what a good approach to do this is. There are several options:

  1. Use an iframe with the content from the Phoenix app.
  2. Use Nginx and SSI to “merge” the html from the Phoenix app and the Rails app
  3. Some solution I haven’t thought of :slight_smile:

The iframe solution is a bit cumbersome when we for example want the iframe to trigger actions in the surrounding page (like showing a modal popup for example).

The SSI solution is nice from a integration standpoint, but I am a bit worried about the security (see https://medium.com/@shatabda/security-ssi-injection-what-how-fbce1dc232b9 for an example).

Does anyone have any advice with respect to 1 or 2 or maybe have another solution?

Have you checked https://hexdocs.pm/terraform/Terraform.html?

Yes, thanks :slight_smile:

My impression is that Terraform works on more of a per request level and I am looking more into an approach where the html from the Phoenix app is mixed with html from the Rails app to have one unified html page.

So far it seems that SSI (Server Side Includes) is the best way to do that (I have a working test setup).

I think you’ll have lots of issues with just embedding pages in a similar manner and cross-domain cookies security will probably be the first.

At this point I’d opt for adding an API to my Phoenix app.