Deploying Wix behind Cloudfront?

Hi! I’m looking to deploy Wix behind a Cloudfront distribution. For example, sub.mysite.org has a CNAME to aaaaaaa.cloudfront.net, which then points to origin www.mywixsite.org. It appears to be pulling the correct Wix site, but I get a javascript error on load.

In the below function within site.js, pageInfo.routerDefinition errors as pageInfo is null.

Is my use case supported? If so, why is pageInfo null, and is there anything that can be done about it?

Thanks!

    function prepareSiteForRender(siteData, viewerPrivateServices, props) { 
        return new Promise(function (resolve) { 
            function oncePageInfoIsAvailable(pageInfo) { 
                siteData.setRootNavigationInfo(pageInfo); 
                utils.logger.reportBeatEvent(siteData, 6, pageInfo.pageId); 
                reportPerformance(siteData); 
                siteBI.init(siteData); 

                var pageLoadedCallback = function () { 
                    executeHooks(hookTypes.PAGE_LOADED_FIRST_RENDER, [siteData, props.wixCodeAppApi]); 

                    /* 
                     * We need to parse url becuase now that the master page data has lodaded, we can extract more info from url 
                     * */ 
                    //todo if dynamicRouter we should know pageId by now, fix pageInfo so that this code may do exactly what it's doing for static pages 
                    var inner_pageInfo = utils.wixUrlParser.parseUrl(siteData, siteData.currentUrl.full); 
                    if (inner_pageInfo.pageId !== pageInfo.pageId) { 
                        inner_pageInfo.pageId = pageInfo.pageId; 
                        inner_pageInfo.title = pageInfo.title; 
                    } 

                    if (coreUtils.errorPages.isErrorPage(inner_pageInfo.pageId)) { 
                        coreUtils.errorPages.setIsFixingDisplayedMasterPage(); 
                        coreUtils.errorPages.updateErrorPageMasterData('masterPage', siteData.pagesData.masterPage); 
                    } 
                    siteData.setRootNavigationInfo(inner_pageInfo); 
                    utils.mobileViewportFixer.fixViewportTag(siteData); 
                    updateUrlIfNeeded(siteData, inner_pageInfo); 

                    resolve({ 
                        siteData: siteData, 
                        viewerPrivateServices: viewerPrivateServices 
                    }); 
                }; 
                viewerPrivateServices.siteDataAPI.loadPage(pageInfo, pageLoadedCallback); 
            } 

            var pageInfo = utils.wixUrlParser.parseUrl(siteData, siteData.currentUrl.full); 
            **if (experiment.isOpen('sv_dpages', siteData) &&** ***pageInfo.routerDefinition*** **) {** 

                relativeRedirectCounter = 0; //this is the first call for getDynamicPageRealPage, init the redirect counter to prevent loops 

                getDynamicPageRealPage(siteData, pageInfo, function (navPageInfo) { 
                    oncePageInfoIsAvailable(navPageInfo); 
                }); 
                return; 
            } 
            oncePageInfoIsAvailable(pageInfo); 
        }); 
    }

Why do you want to deploy wix behind cloudfront?

Wix is already served from CDN (all but a single requests are via a CDN).

Hi Yoav,

The primary motivation is to have Wix serve one of many subdomains on a primary site. In other words, to have sub.mysite.org hosted by Wix, but main1.mysite.org, main2.mysite.org, etc. hosted elsewhere.

After some research and consultation with Wix support, it appears this isn’t possible with DNS alone. The current thought was to have our DNS point sub.mysite.org to a CDN (or could be a simple proxy server), which then gets content from our Wix site. Retrieving the content works, but I run into the Javascript error above.

Thanks!

@yoav-wix Hello! A few years late to the party here but I have a similar question. Is it possible to proxy from my own server (Cloudfront currently but could be nginx or anything else) hosting my pre-existing site to a Wix site under a path prefix?
For example, say I already own and manage www .example .com, and it is already hosted elsewhere. Is there a way I can have that server take all requests to www. example .com/something and proxy them to the Wix site?

I am also curious about this. In my case I would like Wix to serve on the main domain www.example.com and Cloudfront on subdirectories of this domain e.g www.example.com/subdirectory.
I was considering to have the Wix url of my site (username.wix.com/example) as a custom Cloudfront origin, with the www.example.com pointing to the Cloudfront distribution aaaaaaa.cloudfront.net .

Hi, I have the same requirement. Can you please let me know if you ever got a solution for it.