Friday, 15 April 2011

javascript - nginx/angular/node.js root URL with prerender.io -


We have been using an angular SPA node, NGN, and Our home page is set as a unique URL (i.e. www.foo.com/bar) and in our routing, this home page does not specifically make the default redirect of other root-relative URLs specially otherwise.

Our problem is: Root URL comes back with a blank page scrap for www.foo.com or www.foo.com/ Google and Facebook Our index is a NG is the basic basic template in which all pages are inserted from inside, so it is understood that our root URL returns without any real HTML body content. Key HTML in the index:

  & lt; Div class = "st-content" & gt; & Lt; Div ng-view = "" class = "main-content" id = "main view" & gt; & Lt; / Div & gt; & Lt; Div ng-include = "'/ views / footer.html'" & gt; & Lt; / Div & gt; & Lt; / Div & gt; In addition, we have tried other solutions without positive results:  
  • The base tag linking the '/' in the index head, which would not break anything ...
  • 307 redirects, no results
  • Nginx configuration looks good

    Note: In-house routing for '/' Write this question to me to change:

     . When ('/', {templateUrl: '/ views / foo-bar.html', Title: 'Foo Bar', Page Description: 'Larm Ipsum Fu Bar'}). . . Otherwise ({redirectTo: '/'});  

    If this is changed, will the scrap of the house still show in the blank form? Is it basically not the same JS redirection problem, but with fewer characters?

You have to set the window.prerenderReady variable. Thus, place it in your root controller:

  window.prerenderReady = false;  

... and this is the success of your controller in the callback function:

window.prerenderReady = true;


No comments:

Post a Comment