Ich versuche, HTML5Mode zu verwenden. Ich bin wie folgt aus:angularjs - html5mode ist kein Verhalten wie erwartet
Ich verwende 'base' Tag mit href Satz auf '/' in 'Kopf' Tag (kann nicht schreiben in HTML ...)
Und mein Haupt Modul behandelt Routen wie bei Gebrüll:
angular.module('MyChef', [
'Authentication',
'Home',
'UserArea',
'ngRoute',
'ngCookies'
])
.config(['$routeProvider', '$locationProvider', function ($routeProvider,$locationProvider) {
$routeProvider
.when('/login', {
controller: 'LoginController',
templateUrl: 'modules/authentication/views/login.html'
})
.when('/', {
controller: 'HomeController',
templateUrl: 'modules/home/views/home.html'
})
.when('/home', {
controller: 'HomeController',
templateUrl: 'modules/home/views/home.html'
})
.when('/user-area', {
controller: 'UserAreaController',
templateUrl: 'modules/user-area/views/user-area.html'
})
.otherwise({ redirectTo: '/' });
$locationProvider.html5Mode({
enabled: true,
requireBase: false,
});
}]).run(//doesn't matter I guess...);
wie man sehen kann ich versuchen zu verwenden ‚requireBase‘ gesetzt als ‚falsch‘ Hash in meinen Pfaden zu ignorieren, aber funktioniert nicht.
Meine nginx Konfigurationsdatei:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/site/public;
server_name mychefake.com.br;
location/{
index index.html;
try_files $uri $uri/ =404;
}
location /api {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Port 443; #this is important for Catalyst Apps!
rewrite /api(.*) /$1 break;
proxy_pass http://localhost:5000; #changed from http://localhost:5000/
}
}
Das Verhalten:
Wenn ich auf so etwas wie: http://localhost
I '/ login' umgeleitet bin (wenn ich nicht angemeldet bin -im). Das ist ok!
Aber, wenn ich versuche, diese Seite ohne '#' neu zu laden, habe ich 404 Seite in meinem Gesicht. Warum?
Ich nehme an, dass ich etwas auf Nginx-Konfigurationsdatei (vielleicht ein Neuschreiben) tun muss. Habe ich recht oder kann ich das direkt auf AngularJS tun?
Danke!
Nun, die Datei existiert (index.html?!?) Existiert! Aber es ist möglich, dass ich nicht genau verstehe, wovon du redest (Sorry!). Wie auch immer, ich habe keine Ahnung, wie man diese Apache-Befehle auf nginx reproduziert (Ausnahme für RewriteRule). Recherchieren ... –