2
脚本的链接来设置基准标签在HTML5模式下运行角1.x中后,浏览器(Chrome)访问时提出的要求,为脚本错误的道路直接导航至localhost:3000/resource/id
。
详细
我有一个角1个应用程序,我最近设置在HTML5模式下运行,就像这样:
$locationProvider.html5Mode(true);
我已经计入指数的头一个基本标记。 HTML像这样:
<base href="/">
我已经建立了我的快递路线,这样的(例如)http://localhost:3000/album/38ad87f
将返回的请求dex.html,如下所示:
.use('/', express.static(__dirname + '/crate-frontend/app'))
// Playlist endpoints
.use('/api/playlists', playlistRoutes)
// Album endpoints
.use('/api/album', albumRoutes)
// Artist endpoints
.use('/api/artist', artistRoutes)
// Track endpoints
.use('/api/tracks', trackRoutes)
// User endpoints
.use('/api/user', userRoutes)
// Discogs proxy endpoints
.use('/api/discogs', discogsRoutes)
// Youtube proxy endpoints
.use('/api/youtube', youtubeRoutes)
// Search endpoints
.use('/api/search', searchRoutes)
// For serving up crate-frontend/app/index.html
.all('/*', function(request, response){
response.sendFile(__dirname + '/crate-frontend/app/index.html');
})
现在,当我转到主页并浏览时,一切正常。但是,如果我刷新不是根的页面或复制/粘贴http://localhost:3000/album/38ad87f
这样的URL到一个新窗口中,它会中断。我可以看到它接收的index.html,但是当浏览器请求的每个链接的脚本,例如:
<script src="app.js"></script>
它实际上使http://localhost:3000/album/app.js
请求,返回的index.html。
有人能告诉我我错过了什么/做错了吗?
嗯,我觉得笨,但我很高兴我问。非常感谢! – marcushaddon
@marcushaddon很乐意帮助你。 – lin