Can I host the same react app at two different paths on my website?What is the difference between state and props in React?What's the difference between “super()” and “super(props)” in React when using es6 classes?Can you force a React component to rerender without calling setState?What is the difference between using constructor vs getInitialState in React / React Native?What is the difference between React Native and React?React Router with optional path parameterMultiple path names for a same component in React Routerreact router html5 pushstae with NginxHow to write NGINX config file to use ReactJS? (on Docker)how to setup nginx having react pwa in one folder and php apis in other?

What could a reptilian race tell by candling their eggs?

If two black hole event horizons overlap (touch) can they ever separate again?

Can the passive "être + verbe" sometimes mean the past?

Does anyone know what these symbols mean?

Why transcripts instead of degree certificates?

Was it really unprofessional of me to leave without asking for a raise first?

Why is my line not appearing smooth?

What's the safest way to inform a new user of their password on my web site?

Why do the keys in the circle of fifths have the pattern of accidentals that they do?

How can I reduce the sound of rain on a range hood vent?

What's the easiest way for a whole party to be able to communicate with a creature that doesn't know Common?

Did Wakanda officially get the stuff out of Bucky's head?

Averting Real Women Don’t Wear Dresses

How to fix a dry solder pin in BGA package?

How did installing this RPM create a file?

Why won't the ground take my seed?

Inquiring about the possibility of a job

Questions about authorship rank and academic politics

Should I report a leak of confidential HR information?

Do space suits measure "methane" levels or other biological gases?

Symbol for "not absolutely continuous" in Latex

How can a valley surrounded by mountains be fertile and rainy?

Can I travel from Germany to England alone as an unaccompanied minor?

Are there any features that help with the roll to avoid the destruction of a Wand of Fireballs when using the last charge?



Can I host the same react app at two different paths on my website?


What is the difference between state and props in React?What's the difference between “super()” and “super(props)” in React when using es6 classes?Can you force a React component to rerender without calling setState?What is the difference between using constructor vs getInitialState in React / React Native?What is the difference between React Native and React?React Router with optional path parameterMultiple path names for a same component in React Routerreact router html5 pushstae with NginxHow to write NGINX config file to use ReactJS? (on Docker)how to setup nginx having react pwa in one folder and php apis in other?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















My current setup



  • I have a website made with basic html+css. (say https://example.com)

  • I have hosted a react app at https://example.com/register

To do so, I have set in my package.json



"homepage": "https://example.com/register/"


and on my App.js



<Router history=history basename="/register">
</Router>


My NGINX looks like this:



server 
listen 5400;
access_log /var/log/nginx/wordpress-access.log;
error_log /var/log/nginx/wordpress-error.log;
location /
root /home/ubuntu/...../build/;
index index.html;
expires 1d;
try_files $uri /index.html;





server
listen 443 ssl;
listen [::]:443;
index index.php index.html index.htm;
server_name example.com;
location /
... old setup

location /register
proxy_pass http://127.0.1.1:5400/;





Here is what I want to do. I want to host the same react app at the url example.com/pricing.



How can I achieve this? I want to have the least duplication of code/logic etc.










share|improve this question






























    2















    My current setup



    • I have a website made with basic html+css. (say https://example.com)

    • I have hosted a react app at https://example.com/register

    To do so, I have set in my package.json



    "homepage": "https://example.com/register/"


    and on my App.js



    <Router history=history basename="/register">
    </Router>


    My NGINX looks like this:



    server 
    listen 5400;
    access_log /var/log/nginx/wordpress-access.log;
    error_log /var/log/nginx/wordpress-error.log;
    location /
    root /home/ubuntu/...../build/;
    index index.html;
    expires 1d;
    try_files $uri /index.html;





    server
    listen 443 ssl;
    listen [::]:443;
    index index.php index.html index.htm;
    server_name example.com;
    location /
    ... old setup

    location /register
    proxy_pass http://127.0.1.1:5400/;





    Here is what I want to do. I want to host the same react app at the url example.com/pricing.



    How can I achieve this? I want to have the least duplication of code/logic etc.










    share|improve this question


























      2












      2








      2








      My current setup



      • I have a website made with basic html+css. (say https://example.com)

      • I have hosted a react app at https://example.com/register

      To do so, I have set in my package.json



      "homepage": "https://example.com/register/"


      and on my App.js



      <Router history=history basename="/register">
      </Router>


      My NGINX looks like this:



      server 
      listen 5400;
      access_log /var/log/nginx/wordpress-access.log;
      error_log /var/log/nginx/wordpress-error.log;
      location /
      root /home/ubuntu/...../build/;
      index index.html;
      expires 1d;
      try_files $uri /index.html;





      server
      listen 443 ssl;
      listen [::]:443;
      index index.php index.html index.htm;
      server_name example.com;
      location /
      ... old setup

      location /register
      proxy_pass http://127.0.1.1:5400/;





      Here is what I want to do. I want to host the same react app at the url example.com/pricing.



      How can I achieve this? I want to have the least duplication of code/logic etc.










      share|improve this question
















      My current setup



      • I have a website made with basic html+css. (say https://example.com)

      • I have hosted a react app at https://example.com/register

      To do so, I have set in my package.json



      "homepage": "https://example.com/register/"


      and on my App.js



      <Router history=history basename="/register">
      </Router>


      My NGINX looks like this:



      server 
      listen 5400;
      access_log /var/log/nginx/wordpress-access.log;
      error_log /var/log/nginx/wordpress-error.log;
      location /
      root /home/ubuntu/...../build/;
      index index.html;
      expires 1d;
      try_files $uri /index.html;





      server
      listen 443 ssl;
      listen [::]:443;
      index index.php index.html index.htm;
      server_name example.com;
      location /
      ... old setup

      location /register
      proxy_pass http://127.0.1.1:5400/;





      Here is what I want to do. I want to host the same react app at the url example.com/pricing.



      How can I achieve this? I want to have the least duplication of code/logic etc.







      reactjs react-router






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 12:48







      Ranjith Ramachandra

















      asked Mar 25 at 12:46









      Ranjith RamachandraRanjith Ramachandra

      4,4467 gold badges35 silver badges77 bronze badges




      4,4467 gold badges35 silver badges77 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          2














          One solution is to do two separate builds, one for /register and one for /pricing.



          Instead of using the homepage field in your package.json to specify the root, you could use the environment variable PUBLIC_URL for that and add a custom environment variable called e.g. REACT_APP_BASENAME that you use for the basename prop of your Router.



          <Router history=history basename=process.env.REACT_APP_BASENAME>


          Your build scripts could then look like this:



          "build:register": "PUBLIC_URL=https://example.com/register/ REACT_APP_BASENAME=/register node scripts/build.js",
          "build:pricing": "PUBLIC_URL=https://example.com/pricing/ REACT_APP_BASENAME=/pricing node scripts/build.js"





          share|improve this answer






























            0














            This might not work for your particular setup, but react-router v5 has a new feature that allows for multiple matchers for the same component:



            // Instead of this:
            <Switch>
            <Route path="/users/:id" component=User />
            <Route path="/profile/:id" component=User />
            </Switch>

            // you can now do this:
            <Route path=["/users/:id", "/profile/:id"] component=User />


            https://reacttraining.com/blog/react-router-v5/#new-features






            share|improve this answer


















            • 1





              Thanks for your answer. I know about this but it won't work in my case because I am using alongside my existing website at a different location.

              – Ranjith Ramachandra
              Mar 25 at 18:43













            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55338157%2fcan-i-host-the-same-react-app-at-two-different-paths-on-my-website%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            One solution is to do two separate builds, one for /register and one for /pricing.



            Instead of using the homepage field in your package.json to specify the root, you could use the environment variable PUBLIC_URL for that and add a custom environment variable called e.g. REACT_APP_BASENAME that you use for the basename prop of your Router.



            <Router history=history basename=process.env.REACT_APP_BASENAME>


            Your build scripts could then look like this:



            "build:register": "PUBLIC_URL=https://example.com/register/ REACT_APP_BASENAME=/register node scripts/build.js",
            "build:pricing": "PUBLIC_URL=https://example.com/pricing/ REACT_APP_BASENAME=/pricing node scripts/build.js"





            share|improve this answer



























              2














              One solution is to do two separate builds, one for /register and one for /pricing.



              Instead of using the homepage field in your package.json to specify the root, you could use the environment variable PUBLIC_URL for that and add a custom environment variable called e.g. REACT_APP_BASENAME that you use for the basename prop of your Router.



              <Router history=history basename=process.env.REACT_APP_BASENAME>


              Your build scripts could then look like this:



              "build:register": "PUBLIC_URL=https://example.com/register/ REACT_APP_BASENAME=/register node scripts/build.js",
              "build:pricing": "PUBLIC_URL=https://example.com/pricing/ REACT_APP_BASENAME=/pricing node scripts/build.js"





              share|improve this answer

























                2












                2








                2







                One solution is to do two separate builds, one for /register and one for /pricing.



                Instead of using the homepage field in your package.json to specify the root, you could use the environment variable PUBLIC_URL for that and add a custom environment variable called e.g. REACT_APP_BASENAME that you use for the basename prop of your Router.



                <Router history=history basename=process.env.REACT_APP_BASENAME>


                Your build scripts could then look like this:



                "build:register": "PUBLIC_URL=https://example.com/register/ REACT_APP_BASENAME=/register node scripts/build.js",
                "build:pricing": "PUBLIC_URL=https://example.com/pricing/ REACT_APP_BASENAME=/pricing node scripts/build.js"





                share|improve this answer













                One solution is to do two separate builds, one for /register and one for /pricing.



                Instead of using the homepage field in your package.json to specify the root, you could use the environment variable PUBLIC_URL for that and add a custom environment variable called e.g. REACT_APP_BASENAME that you use for the basename prop of your Router.



                <Router history=history basename=process.env.REACT_APP_BASENAME>


                Your build scripts could then look like this:



                "build:register": "PUBLIC_URL=https://example.com/register/ REACT_APP_BASENAME=/register node scripts/build.js",
                "build:pricing": "PUBLIC_URL=https://example.com/pricing/ REACT_APP_BASENAME=/pricing node scripts/build.js"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 14:40









                TholleTholle

                49k7 gold badges62 silver badges84 bronze badges




                49k7 gold badges62 silver badges84 bronze badges























                    0














                    This might not work for your particular setup, but react-router v5 has a new feature that allows for multiple matchers for the same component:



                    // Instead of this:
                    <Switch>
                    <Route path="/users/:id" component=User />
                    <Route path="/profile/:id" component=User />
                    </Switch>

                    // you can now do this:
                    <Route path=["/users/:id", "/profile/:id"] component=User />


                    https://reacttraining.com/blog/react-router-v5/#new-features






                    share|improve this answer


















                    • 1





                      Thanks for your answer. I know about this but it won't work in my case because I am using alongside my existing website at a different location.

                      – Ranjith Ramachandra
                      Mar 25 at 18:43















                    0














                    This might not work for your particular setup, but react-router v5 has a new feature that allows for multiple matchers for the same component:



                    // Instead of this:
                    <Switch>
                    <Route path="/users/:id" component=User />
                    <Route path="/profile/:id" component=User />
                    </Switch>

                    // you can now do this:
                    <Route path=["/users/:id", "/profile/:id"] component=User />


                    https://reacttraining.com/blog/react-router-v5/#new-features






                    share|improve this answer


















                    • 1





                      Thanks for your answer. I know about this but it won't work in my case because I am using alongside my existing website at a different location.

                      – Ranjith Ramachandra
                      Mar 25 at 18:43













                    0












                    0








                    0







                    This might not work for your particular setup, but react-router v5 has a new feature that allows for multiple matchers for the same component:



                    // Instead of this:
                    <Switch>
                    <Route path="/users/:id" component=User />
                    <Route path="/profile/:id" component=User />
                    </Switch>

                    // you can now do this:
                    <Route path=["/users/:id", "/profile/:id"] component=User />


                    https://reacttraining.com/blog/react-router-v5/#new-features






                    share|improve this answer













                    This might not work for your particular setup, but react-router v5 has a new feature that allows for multiple matchers for the same component:



                    // Instead of this:
                    <Switch>
                    <Route path="/users/:id" component=User />
                    <Route path="/profile/:id" component=User />
                    </Switch>

                    // you can now do this:
                    <Route path=["/users/:id", "/profile/:id"] component=User />


                    https://reacttraining.com/blog/react-router-v5/#new-features







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 25 at 18:33









                    worcworc

                    1,7703 gold badges21 silver badges28 bronze badges




                    1,7703 gold badges21 silver badges28 bronze badges







                    • 1





                      Thanks for your answer. I know about this but it won't work in my case because I am using alongside my existing website at a different location.

                      – Ranjith Ramachandra
                      Mar 25 at 18:43












                    • 1





                      Thanks for your answer. I know about this but it won't work in my case because I am using alongside my existing website at a different location.

                      – Ranjith Ramachandra
                      Mar 25 at 18:43







                    1




                    1





                    Thanks for your answer. I know about this but it won't work in my case because I am using alongside my existing website at a different location.

                    – Ranjith Ramachandra
                    Mar 25 at 18:43





                    Thanks for your answer. I know about this but it won't work in my case because I am using alongside my existing website at a different location.

                    – Ranjith Ramachandra
                    Mar 25 at 18:43

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55338157%2fcan-i-host-the-same-react-app-at-two-different-paths-on-my-website%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현