herhangi bir açısal rotaya herhangi bir param veya sorgu eklediğimde, tarayıcı isteğim, css dosyam için url isteğine bu şekilde param ekler.açısal params ve ekspres yanlış req url
Ben gerçek html5mode (tatlı URL'ler)
.state('profile', {
url: "/profile/:steamId",
templateUrl: "app/profile/profile.html",
controller: "ProfileCtrl",
controllerAs: "profile",
data: {
contentPages: 1
}
});
$locationProvider.html5Mode(true);
Benim açısal hizmet
getProfile:function(steamId){
var self = this;
return $http.get('api/user/'+steamId).then(function(response){
$log.debug('getProfile', response.data);
return response.data;
}, function(err){
$log.error('Error user', err);
});
},
kullanıyorum ve benim sunucuda
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
// Launch ======================================================================
var server = app.listen(8000, function(){
logger.info('The dagger flies at 8000');
});
// Configuration ======================================================================
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/public'));
// Routes ======================================================================
var users = require('./routes/users.route')(passport, logger);
// Middleware ======================================================================
app.use('/api/users', users);
app.get('/*', function(req, res, next) {
res.sendFile('index.html', { root: 'public' });
});
benim index.html bunun için kurulur
<link rel="stylesheet" href="builds/style.css"/>
Normalde ben localhost üzerinde olduğum zaman benim ağ sekmesinde şöyle bir şey görmek: Örneğin
http://localhost:8000/builds/style.css
için 8000/profile ama bu
localhost:8000/profile/13456
gibi bir param eklediğinizde benim Ağ sekmesi, bu
http://localhost:8000/profile/builds/style.css
ve dolayısıyla bir grup hecml kodunun kullanılmadığını görüyorum.
Bunu nasıl düzeltebilirim? Ekspres durağan ara katman yazılımı ile uğraşmayı denedim ama başarı yok.
Eğer href mevcut adresinden kaynak yüklenmeye çalışır ' "/ style.css kurar"=' atıfta çünkü. 'Href = "/ builds/style.css" ' –