2015-09-06 93 views
0

我正在提供来自快递的角页面。我无法预渲染就可以提供显示的页面为产品:Prerender没有提供产品

http://www.minilolo.com/?_escaped_fragment_=/products/Lolo-Pink

但是其他个这样的页面都OK:

http://www.minilolo.com/?_escaped_fragment_=/products

我想我可能需要添加一些快递路线,但想知道我是否在正确的轨道上。谢谢!

var express = require('express'); 
var path = require('path'); 
var favicon = require('serve-favicon'); 
var logger = require('morgan'); 
var cookieParser = require('cookie-parser'); 
var bodyParser = require('body-parser'); 

var app = express(); 

// uncomment after placing your favicon in /public 
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 
app.use(logger('dev')); 
app.use(bodyParser.json()); 
app.use(bodyParser.urlencoded({ extended: false })); 
app.use(cookieParser()); 
app.set('view engine', 'ejs'); 

app.use(require('prerender-node').set('prerenderToken', 'xyz123')); 

/** 
* Development Settings 
*/ 
if (app.get('env') === 'development') { 
    // This will change in production since we'll be using the dist folder 
    app.use(express.static(path.join(__dirname, '../client'))); 
    // This covers serving up the index page 
    app.use(express.static(path.join(__dirname, '../client/.tmp'))); 
    app.use(express.static(path.join(__dirname, '../client/app'))); 


    // Error Handling 
    app.use(function(err, req, res, next) { 
     res.status(err.status || 500); 
     res.render('error', { 
      message: err.message, 
      error: err 
     }); 
    }); 
} 

/** 
* Production Settings 
*/ 
if (app.get('env') === 'production') { 

    // changes it to use the optimized version for production 
    app.use(express.static(path.join(__dirname, 'dist'))); 
    // added to serve up products pages 
    app.use(function(req, res) { 
     // Use res.sendfile, as it streams instead of reading the file into memory. 
     res.sendfile(__dirname + '/dist/index.html'); 
    }); 

    // production error handler 
    // no stacktraces leaked to user 
    app.use(function(err, req, res, next) { 
     res.status(err.status || 500); 
     res.render('error', { 
      message: err.message, 
      error: {} 
     }); 
    }); 
} 

module.exports = app; 

编辑:我已经找到了问题预渲染转换成 '_escaped_fragment_ =?' '#!'。 Angular然后不知道要使用哪个路由,除非我有$ locationProvider.hashPrefix('!')(就是我不想使用的)。如果可以提供帮助,我不需要#前缀。

2015-09-07T12:17:17.566Z got 200 in 12713ms for http://localhost:3000/#!/products 
2015-09-07T12:17:18.773Z Timed out. Sending request with HTML on the page 
2015-09-07T12:17:18.785Z got 200 in 12732ms for http://localhost:3000/#!/products 
2015-09-07T12:19:04.589Z getting http://localhost:3000/#!/products 
+0

你提供的链接看起来好像对我来说很好。有什么问题? –

+0

它提供的内容来自[http://www.minilolo.com/](http://www.minilolo.com/),而不是实际的产品页面[http://www.minilolo.com/products/洛洛粉红](http://www.minilolo.com/products/Lolo-Pink) – user1074891

回答