javascript - When I navigate to a route directly i get server output, but when I use a link i get the view rendered correctly -
i'm noob , working on mean.js boilerplate.
i've created routes, i'm having issue, where, when navigate route ('/articles') server output this:
[{"_id":"5553aa4116a2fddc830b0f66","user":{"_id":"5552398fcf7ada7563db68b7","displayname":"mo bazazi"},"__v":0,"content":"wahattata","title":"fifth examples","created":"2015-05-13t19:47:13.905z"}]
but want ge rendered view, when manually type in route - have suggestions?
here part of express config
use strict'; /** * module dependencies. */ var fs = require('fs'), http = require('http'), https = require('https'), express = require('express'), morgan = require('morgan'), bodyparser = require('body-parser'), session = require('express-session'), compress = require('compression'), methodoverride = require('method-override'), cookieparser = require('cookie-parser'), helmet = require('helmet'), passport = require('passport'), mongostore = require('connect-mongo')({ session: session }), flash = require('connect-flash'), config = require('./config'), consolidate = require('consolidate'), path = require('path'); module.exports = function(db) { // initialize express app var app = express(); // globbing model files config.getglobbedfiles('./app/models/**/*.js').foreach(function(modelpath) { require(path.resolve(modelpath)); }); // setting application local variables app.locals.title = config.app.title; app.locals.description = config.app.description; app.locals.keywords = config.app.keywords; app.locals.facebookappid = config.facebook.clientid; app.locals.jsfiles = config.getjavascriptassets(); app.locals.cssfiles = config.getcssassets(); // passing request url environment locals app.use(function(req, res, next) { res.locals.url = req.protocol + '://' + req.headers.host + req.url; next(); }); // should placed before express.static app.use(compress({ filter: function(req, res) { return (/json|text|javascript|css/).test(res.getheader('content-type')); }, level: 9 })); // showing stack errors app.set('showstackerror', true); // set swig template engine app.engine('server.view.html', consolidate[config.templateengine]); // set views path , view engine app.set('view engine', 'server.view.html'); app.set('views', './app/views');
so claies right - html5 issue - i've been working on little , trying set catch express config - i've added section below:
// setting app router , static folder app.use(express.static(path.resolve('./public'))); app.get('/', function(req, res) { res.render('index'); }); // globbing routing files config.getglobbedfiles('./app/routes/**/*.js').foreach(function(routepath) { require(path.resolve(routepath))(app); }); app.get('*', function(req, res) { res.redirect('/'); });
the problem i'm using mean.js boilerplate, , have custom glob based routing, doesn't play catchall i.e. resources wont work catchall are, although rerouting correct templates - thoughts?
Comments
Post a Comment