@nakedcreativity/cee-ms-node 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +6 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -136,7 +136,7 @@ ceems.prototype.load = function(req, res){
|
|
|
136
136
|
var path = req._parsedUrl.pathname.substring(1)
|
|
137
137
|
if(path == '')
|
|
138
138
|
path = 'home'
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
this.site = JSON.parse(fs.readFileSync('./pages/site.json', 'utf8'));
|
|
141
141
|
//this.pages_map = _.indexBy(this.site.pages, 'url');
|
|
142
142
|
|
|
@@ -160,7 +160,10 @@ ceems.prototype.load = function(req, res){
|
|
|
160
160
|
// 404
|
|
161
161
|
else{
|
|
162
162
|
console.log('404 for ',path)
|
|
163
|
-
res.status(404)
|
|
163
|
+
res.status(404)
|
|
164
|
+
// .send('Sorry, this page does not exist');
|
|
165
|
+
var notFound = this.site.pages['404']
|
|
166
|
+
return JSON.parse(fs.readFileSync('./pages/'+notFound._id+'.json', 'utf8'))
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
|
|
@@ -189,7 +192,7 @@ ceems.prototype.render = function(req, res, page=null) {
|
|
|
189
192
|
if(this.config.whitelistedCookies){
|
|
190
193
|
page.cookies = []
|
|
191
194
|
_.each(this.config.whitelistedCookies, cookieName=>{
|
|
192
|
-
if(req.cookies[cookieName]){
|
|
195
|
+
if(req.cookies && req.cookies[cookieName]){
|
|
193
196
|
page.cookies[cookieName] = req.cookies[cookieName]
|
|
194
197
|
}
|
|
195
198
|
})
|