Apostrophe CMS Main Site Forum Home

Integrating Apostrophe CMS into an existing Node App


Hi everyone! I’m considering Apostrophe CMS as a blog manager for an existing React/Express/Node App because unlike the other solutions, I like how Apostrophe can potentially make it easy for my admin users to edit blog entries. What’s the recommended approach to integrate Apostrophe? Should I study how it works and merge the dependencies into package.json and all the other files into my existing file structure? Or is there a way to make it work from a subfolder and just do some routing to its own app.js?



Hi niawdeleon,

It’s possible to convince Apostrophe to run from a “subdirectory” (i.e. prefix all URLs with a given string). It’s not the primary use case but we have the occasional client who insists on it, and then they use their reverse proxy to map it into their main site, etc.

To do that, you set the “prefix” option in app.js. It’s a top-level option, like shortName. You don’t pass it to a specific module.

Once you do that, you’ll have to go to http://localhost:3000/your-prefix to see the home page when testing, and so on.

As for accessing the blog content from React, it’s very easy to add APIs that respond with JSON, HTML, etc. via the self.route method of any module.


… In that scenario it would probably be easiest to put an Apostrophe app in a subdirectory of your project, too, as far as source code management goes, so it can have its own package.json. Not that it isn’t possible to build an apos object in an unrelated app, you could do that. Our test harness builds dozens of apos objects in a single process, they don’t interfere with each other or the rest of your code.


… But having Apostrophe on one port # and the main app on another, with separate source folders/subdirectories, would come closer to the common node.js approach of creating a fleet of single-purpose applications that talk to each other.


Putting it in its own subdirectory means it will need its own node instance on a different port, correct? The reverse proxy arrangement seems to be something I can do. Thanks for much for the detailed response.