angular-seo
angular-seo copied to clipboard
Not working with Node/ExpressJS/MongoDB setup
My Angular app is built using Node.JS with ExpressJS and calls in data from MongoDB (via MongoLabs).
I'm trying to use this method as described in your readme, but I can't get it to work. I've never used PhantomJS so I may be doing this wrong, here are my steps:
- Added 'seo' to my app's modules
- I'm using
$locationProvider.html5Mode(true);, so I have<meta name="fragment" content="!">in my head. - I'm using your
$scope.htmlReady();in my controller - I installed PhantomJS using Homebrew
- My app is running via node, at http://localhost:5000.
- I run phantomjs --disk-cache=no angular-seo-server.js 5000 http://localhost:5000/
- I try to
curlmy search page,curl http://localhost:5000/?_escaped_fragment_=/search%3Fgender=Womens/0, and I see my template come up but I see none of my partials (just the base template with my head, body tag, scripts and footer), and there are a few{{curly braces}}in there that load in data from Angular but these are not rendered in my Curl request.
Is this an issue in using html5Mode(true) urls? According to this article it should be fine: http://www.yearofmoo.com/2012/11/angularjs-and-seo.html
PhantomJS should not be running at the same port your normal site runs.
Having phantomjs run at 5000 and your site will cause a server conflict.
Change one or the other.
yeah, @reecelewellen is right. also, i don't think you can use html5mode with fragment urls.
I have the same problem. I get my index.html file but with no content in ng-view rendered. I'm not using html5Mode and phantomjs is on another port. My app is running on http://localhost:9000 (yeoman setup). The script seems to return the html in the console immediately like it is not waiting for JS to run. Also, how would this work on a live production site? Could you explain how to have phantomjs running all the time?
hi @jascination , @reecelewellen , @reecelewellen , @steeve ...
I think having a few problems with the server
I'm using below:
-
phantomjs --disk-cache=no angular-seo-server.js {{port1}} http://{{domain_live}}
-
Config nginx server { server_name <%= server_name %> default; listen <%= server_port %>;
location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host;
If not search enging pass static
root "<%= base_dir %>";
if ($args ~ escaped_fragment) { proxy_pass http://{{domain_live}}:{{port1}}; break; }
try_files $uri $uri/ /index.html; } }
Currently, the website using port 8080, this mean when open browser enter http://{{domain_live}} ,it's work fine
Here I have a question that {{domain_live}} and {{port1}} may need another {{port}} or not? and it's should {{port1}} NAT to network?
Because, i has issue 500 Internal Server Error when run http://{{domain_live}}/?escaped_fragment=/type/people/all
Can you help me?
Best regards, Phan Thinh