App Spec for Node + React in Single App

I have a node backend with a react frontend in separate github repos. I have successfully deployed the combo as two separate apps.

But it seems like I should be able to do this as a single app by setting up a service and static site in an app spec.

This seems like it should be a common need. Does anyone know how to make it work?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

OK. The file below worked for me. The last problem was that I had not added my new app instance to the database pool allowed ip’s.

I’m using sequelize on the API server so there are a bunch of environment variables left out of the file below.

- cluster_name: [MY_DATABASE_CLUSTER]
  db_name: [NAME]
  db_user: [USER]
  engine: PG
  name: db-postgresql-NNN
  production: true
  version: "13"
name: app
region: nyc
  - name: backend
    build_command: yarn install
    environment_slug: node-js
      branch: main
      repo: [MY_BACKEND_REPO]
    http_port: 8080
    instance_count: 2
    instance_size_slug: professional-xs
    name: [SERVICE_NAME]
    - path: /api
    run_command: yarn serve
    source_dir: /
    - key: NODE_ENV
      scope: RUN_AND_BUILD_TIME
      value: production
    - key: OTHER_KEY
      scope: RUN_AND_BUILD_TIME
      value: other_value
- build_command: yarn build
  catchall_document: index.html
  environment_slug: html
    scope: BUILD_TIME
    value: my_app_specific_value
    scope: BUILD_TIME
    value: ${APP_URL}
    branch: main
    deploy_on_push: true
    repo: [MY_FRONTEND_REPO]
  name: [static_site_name]
  - path: /
  source_dir: /


App Platform supports adding multiple components from different repositories.

Here is an example of a sample app with multiple components (although in the same repo):

Repo: Spec:

All you would need to do is have a static site with the Github source pointing to your react repository, and a service with the Github source pointing to the nodejs repository.

The one thing you’ll need to be sure to modify is the routes for your app. For example if you want the frontend to be the root, you’d probably want to make the backend something like /api/... etc.

Happy Coding!