검색 중이며 "솔루션"이 발견되었지만 아직 제대로 작동하지 않습니다.AngularJS : html5mode (true)가 켜져있을 때 상대 링크 경로가 깨졌습니다.
시나리오 :
나는 UI 라우터와 각도 (버전 1.2) 웹 사이트를 구축하고 로컬 호스트 노드 서버에서 실행하고 있습니다. 나는 $ locationProvider로 "pretty"url을 만들고 html5 (true)를 on으로 설정하려고 노력하고있다. 내 웹 사이트는 링크를 클릭하면 제대로 작동하지만 상대 링크 경로로 이동하거나 링크 경로를 새로 고침하면 페이지가 중단됩니다. 완료 할 때 나는 또한 Heroku가이 웹 애플리케이션을 배포 할 예정 :
RELATIVE 링크 경로 :
http://localhost:8000/locksmith-services
페이지 출력 결과
Cannot GET /locksmith-services
단계 I 찍은 : 각도에 대한 (내 app.js 파일에서
<base href="/"></base>
2) : 내 "index.html을"< 머리에서
1), 나는 내 기본 URL을 설정 한>
: 이 내 HTML을 같이 쓸 내 탐색에서// App Starts
angular
.module('app', [
'ui.router',
'ngAnimate',
'angular-carousel'
])
.config(['$urlRouterProvider', '$stateProvider', '$locationProvider', function($urlRouterProvider, $stateProvider, $locationProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state('home', {
url: '/',
templateUrl: 'pages/home.html',
controller: 'homeCtrl'
})
.state('services', {
url: '/locksmith-services',
templateUrl: 'pages/locksmith-services.html',
controller: 'servicesCtrl'
})
.state('locations', {
url: '/locksmith-locations',
templateUrl: 'pages/locksmith-locations.html'
})
.state('payment', {
url: '/locksmith-payment',
templateUrl: 'pages/locksmith-payment.html'
})
// use the HTML5 History API
$locationProvider.html5Mode(true);
}])
3), 내가 가진 :), I는 다음과 같이 작성해야
4)
<div class="wrapper">
<a ui-sref="home">
<img src="images/logo.png" class="logo" alt="Austin Texas Locksmith" />
</a>
</div>
<nav class="row navigation">
<a class="mobile33" ui-sref="services" ui-sref-active="active" class="active">Services</a>
<a class="mobile33" ui-sref="locations" ui-sref-active="active">Locations</a>
<a class="mobile33" ui-sref="payment" ui-sref-active="active">Payment</a>
</nav>
는 server.js 파일 (노드 서버)
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/front'));
var port = process.env.PORT || 8000;
app.listen(port);
은 무엇 최적의 솔루션이 될 것입니다 내? 귀하의 도움에 미리 감사드립니다.
도움에 감사드립니다! 내 server.js 파일을 다시 쓰는 것이 트릭을 만들었습니다. – Oneezy