How should I configure create-react-app to serve app from subdirectory?

前端 未结 6 1158
死守一世寂寞
死守一世寂寞 2020-12-08 02:59

I have classic web application rendered on server. I want to create admin panel as single page application in React. I want to server admin panel from https://smyapp.example

6条回答
  •  悲哀的现实
    2020-12-08 03:32

    For create-react-app v2 and react-router v4, I used the following combo to serve a production (staging, uat, etc) app under "/app":

    package.json:

    "homepage": "/app"
    

    Then in the app entry point:

     
      {/* other components */}
     
    

    And everything "just works" across both local-dev and deployed environments. HTH!

提交回复
热议问题