How would you best configure JSS to work with multiple Sitecore ?












4















One of the key benefits I can see from moving to JSS is the way developers can work with the different tools. In particular the lure of Hot Module Replacement (HMR) adds such a lot of positives for development speed. Therefore its key we don't lose this capability - building the whole JSS project for every change would not be a good solution.



We have a traditional Sitecore setup which relies heavily on <sites>. Examples being configured as follows:




  • www.domain.com <= en-ca

  • www.domain.com/fr <= fr-ca

  • www.anotherdomain.com <= en-au

  • www.anotherdomain.com/fr and www.anotherdomain.com/fr-fr shouldn't work


In the non-jss world we are achieving the /fr url chunk via config in <sites> for the french site of: virtualFolder="/fr" physicalFolder="/fr"



When running in headless mode I believe this could be achieved with the configuration of express however how could this be done when doing connected, 'HMR driven development' (jss start:connected) as this by default always runs localhost:3000










share|improve this question





























    4















    One of the key benefits I can see from moving to JSS is the way developers can work with the different tools. In particular the lure of Hot Module Replacement (HMR) adds such a lot of positives for development speed. Therefore its key we don't lose this capability - building the whole JSS project for every change would not be a good solution.



    We have a traditional Sitecore setup which relies heavily on <sites>. Examples being configured as follows:




    • www.domain.com <= en-ca

    • www.domain.com/fr <= fr-ca

    • www.anotherdomain.com <= en-au

    • www.anotherdomain.com/fr and www.anotherdomain.com/fr-fr shouldn't work


    In the non-jss world we are achieving the /fr url chunk via config in <sites> for the french site of: virtualFolder="/fr" physicalFolder="/fr"



    When running in headless mode I believe this could be achieved with the configuration of express however how could this be done when doing connected, 'HMR driven development' (jss start:connected) as this by default always runs localhost:3000










    share|improve this question



























      4












      4








      4








      One of the key benefits I can see from moving to JSS is the way developers can work with the different tools. In particular the lure of Hot Module Replacement (HMR) adds such a lot of positives for development speed. Therefore its key we don't lose this capability - building the whole JSS project for every change would not be a good solution.



      We have a traditional Sitecore setup which relies heavily on <sites>. Examples being configured as follows:




      • www.domain.com <= en-ca

      • www.domain.com/fr <= fr-ca

      • www.anotherdomain.com <= en-au

      • www.anotherdomain.com/fr and www.anotherdomain.com/fr-fr shouldn't work


      In the non-jss world we are achieving the /fr url chunk via config in <sites> for the french site of: virtualFolder="/fr" physicalFolder="/fr"



      When running in headless mode I believe this could be achieved with the configuration of express however how could this be done when doing connected, 'HMR driven development' (jss start:connected) as this by default always runs localhost:3000










      share|improve this question
















      One of the key benefits I can see from moving to JSS is the way developers can work with the different tools. In particular the lure of Hot Module Replacement (HMR) adds such a lot of positives for development speed. Therefore its key we don't lose this capability - building the whole JSS project for every change would not be a good solution.



      We have a traditional Sitecore setup which relies heavily on <sites>. Examples being configured as follows:




      • www.domain.com <= en-ca

      • www.domain.com/fr <= fr-ca

      • www.anotherdomain.com <= en-au

      • www.anotherdomain.com/fr and www.anotherdomain.com/fr-fr shouldn't work


      In the non-jss world we are achieving the /fr url chunk via config in <sites> for the french site of: virtualFolder="/fr" physicalFolder="/fr"



      When running in headless mode I believe this could be achieved with the configuration of express however how could this be done when doing connected, 'HMR driven development' (jss start:connected) as this by default always runs localhost:3000







      jss






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 30 at 11:48







      boro2g

















      asked Jan 30 at 11:32









      boro2gboro2g

      375111




      375111






















          1 Answer
          1






          active

          oldest

          votes


















          4














          When running in connected mode, there is an Express server that runs next to your JSS app (by default at localhost:3000). However, your app is making requests to your Sitecore instance via whatever URL you've defined in the layoutServiceHost property in scjssconfig.json.



          That means you can modify the layoutServiceHost property to use whatever site hostName is appropriate for the <site /> nodes you have defined in your Sitecore instance.



          If you need to modify the layoutServiceHost value at runtime, for instance to reflect some URL fragment or parameter, then you can do so wherever you make a call to dataApi.fetchRouteData (or "globally" in your app wherever you resolve routes). The JSS sample apps make that call in the RouteHandler component (in React and Vue), and you'll see in the getRouteData method of that component that it sets the layoutServiceConfig.host property to the config.sitecoreApiHost value. That value, by default, comes from scjssconfig.json, but as mentioned it can come from anywhere or be modified prior to usage.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "664"
            };
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2fsitecore.stackexchange.com%2fquestions%2f16327%2fhow-would-you-best-configure-jss-to-work-with-multiple-sitecore-sites%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            When running in connected mode, there is an Express server that runs next to your JSS app (by default at localhost:3000). However, your app is making requests to your Sitecore instance via whatever URL you've defined in the layoutServiceHost property in scjssconfig.json.



            That means you can modify the layoutServiceHost property to use whatever site hostName is appropriate for the <site /> nodes you have defined in your Sitecore instance.



            If you need to modify the layoutServiceHost value at runtime, for instance to reflect some URL fragment or parameter, then you can do so wherever you make a call to dataApi.fetchRouteData (or "globally" in your app wherever you resolve routes). The JSS sample apps make that call in the RouteHandler component (in React and Vue), and you'll see in the getRouteData method of that component that it sets the layoutServiceConfig.host property to the config.sitecoreApiHost value. That value, by default, comes from scjssconfig.json, but as mentioned it can come from anywhere or be modified prior to usage.






            share|improve this answer




























              4














              When running in connected mode, there is an Express server that runs next to your JSS app (by default at localhost:3000). However, your app is making requests to your Sitecore instance via whatever URL you've defined in the layoutServiceHost property in scjssconfig.json.



              That means you can modify the layoutServiceHost property to use whatever site hostName is appropriate for the <site /> nodes you have defined in your Sitecore instance.



              If you need to modify the layoutServiceHost value at runtime, for instance to reflect some URL fragment or parameter, then you can do so wherever you make a call to dataApi.fetchRouteData (or "globally" in your app wherever you resolve routes). The JSS sample apps make that call in the RouteHandler component (in React and Vue), and you'll see in the getRouteData method of that component that it sets the layoutServiceConfig.host property to the config.sitecoreApiHost value. That value, by default, comes from scjssconfig.json, but as mentioned it can come from anywhere or be modified prior to usage.






              share|improve this answer


























                4












                4








                4







                When running in connected mode, there is an Express server that runs next to your JSS app (by default at localhost:3000). However, your app is making requests to your Sitecore instance via whatever URL you've defined in the layoutServiceHost property in scjssconfig.json.



                That means you can modify the layoutServiceHost property to use whatever site hostName is appropriate for the <site /> nodes you have defined in your Sitecore instance.



                If you need to modify the layoutServiceHost value at runtime, for instance to reflect some URL fragment or parameter, then you can do so wherever you make a call to dataApi.fetchRouteData (or "globally" in your app wherever you resolve routes). The JSS sample apps make that call in the RouteHandler component (in React and Vue), and you'll see in the getRouteData method of that component that it sets the layoutServiceConfig.host property to the config.sitecoreApiHost value. That value, by default, comes from scjssconfig.json, but as mentioned it can come from anywhere or be modified prior to usage.






                share|improve this answer













                When running in connected mode, there is an Express server that runs next to your JSS app (by default at localhost:3000). However, your app is making requests to your Sitecore instance via whatever URL you've defined in the layoutServiceHost property in scjssconfig.json.



                That means you can modify the layoutServiceHost property to use whatever site hostName is appropriate for the <site /> nodes you have defined in your Sitecore instance.



                If you need to modify the layoutServiceHost value at runtime, for instance to reflect some URL fragment or parameter, then you can do so wherever you make a call to dataApi.fetchRouteData (or "globally" in your app wherever you resolve routes). The JSS sample apps make that call in the RouteHandler component (in React and Vue), and you'll see in the getRouteData method of that component that it sets the layoutServiceConfig.host property to the config.sitecoreApiHost value. That value, by default, comes from scjssconfig.json, but as mentioned it can come from anywhere or be modified prior to usage.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 30 at 12:55









                Adam WeberAdam Weber

                1,535314




                1,535314






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Sitecore Stack Exchange!


                    • 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%2fsitecore.stackexchange.com%2fquestions%2f16327%2fhow-would-you-best-configure-jss-to-work-with-multiple-sitecore-sites%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

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix