How to deploy Strapi backend and ReactJS frontend to a single Heroku app

前端 未结 2 923
孤城傲影
孤城傲影 2021-01-28 06:37

Is there any supported way how to deploy a Strapi backend and a ReactJS frontend into a single Heroku app?

I have successfully deployed the Strapi backend, but am complet

2条回答
  •  失恋的感觉
    2021-01-28 07:06

    If somebody wants to know if Muhammad Ahmad's solution works - yes, it works.

    Initially, I worked exclusively with the MERN stack and used two folders - one for the client, the other for the server. Only package.json was at the root. Everything worked fine on Heroku, so I didn't expect to find it difficult to switch the backend to Strapi...

    Then I decided to try to replace the server side (Express) to Strapi. After that, there was a problem of deploying this whole case to Heroku and running it on single Heroku application.

    So, the project structure is:

    /root 
          - /client (React UI)
          - /server (Strapi)
          - package.json
    

    In order to make the whole thing work together, it is necessary to amend a little change inside

    ./middlewares/serve-react/index.js:

     const staticDir = path.resolve(strapi.dir, clientBuildPath || strapi.config.paths.static);
    

    where clientBuildPath is ../client/build.

提交回复
热议问题