У меня problemas с Backbone.history.start({pushState: true});
когда Активизированныйnodejs ExpressJs BackboneJs PushState
Я использую магистральный маршрутизатор 'example/:id':'test'
и браузер возвращает мне ошибку
GET MyHost: 1337/пример/JS/просмотров /test.js 404 (не найдено)
Я хочу повернуть со спинкой, например myhost:1337/example/test
, без необходимости запрашивать nodejs.
си, я не знаю, почему,
Может быть мой сервер Nodejs? Или Мог ли мой код, что он плохо написан? Заранее спасибо
МОЕГО код сервера
//var http = require('http');
var path = require('path'),
express = require('express'),
routes = require('./routes/index'),
http = require('http'),
app = require('express')();
app.configure(function(){
//app.set('view options',{layout: false });
app.set('port', process.env.PORT || 1337);
app.use(express.bodyParser()),
app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router); // you need this line so the .get etc. routes are run and if an error within, then the error is parsed to the ned middleware (your error reporter)
app.use(function(err, req, res, next) {
if(!err) return next(); // you also need this line
console.log("error!!!");
res.send("error!!!");
});
});
app.get('*',function(req,res){
res.setHeader('content-type', 'text/javascript');
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.redirect('http://localhost:1337#'+req.url);
});
http.createServer(app).listen(app.get('port'), function() {
console.log("Express server listening on port " + app.get('port'));
});
У меня есть этот пример /: id ':' test 'на самом деле. Но я не работаю. Браузер возвращает мне ошибку – oscar
@oscar Это ваш код для магистрального маршрутизатора. Каков ваш код на вашем сервере node.js? –
Я думаю, что nodejs обнаруживают URL-адрес и его поиск для поиска файлов. Я не уверен, что это – oscar