不能得到/页 [英] Cannot GET / page
问题描述
我试图使用咕噜的contrib连接本地开发和测试角的应用程序。
I am trying to use grunt contrib connect for local development and testing of an angular app.
在gruntfile配置,像这样:
the gruntfile is configured like so:
connect: {
server: {
options: {
open: true,
keepalive: true,
hostname: 'localhost',
port: 8080
}
}
}
和任务
grunt.registerTask('serve', [
'connect:server'
]);
咕噜服务
打开与根目录的文件列表的浏览器。点击 DIST
目录中启动应用程序。一切都很好,直到在这里:它可以从应用程序菜单中更改页面,但是......任何这些网页直接访问或重装,给人拿不到/距离/页
...这是要回去`本地主机:8080 /距离,使其重新工作...
grunt serve
opens the browser with the file listing of the root directory. Clicking on the dist
directory launches the app. Everything is fine until here: it's possible to change page from the app menu, but… direct access or reload of any of these pages, gives Cannot GET /dist/page
… It's necessary to go back to `localhost:8080/dist' to make it work again…
我能做的,使这项工作?
What could I do to make this work?
推荐答案
我找到了解决办法这里,使用咕噜< A HREF =https://github.com/tinganho/connect-modrewrite相对=nofollow>连接 - modrewrite
I found a solution here, using grunt connect-modrewrite
繁重的任务,现在是:
server: {
options: {
port: 9000,
livereload: 35729,
hostname: 'localhost',
open: true,
middleware: function (connect) {
return [
modRewrite(['^[^\\.]*$ /index.html [L]']),
connect.static('dist')
];
}
}
}
这篇关于不能得到/页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!