不能得到/页 [英] Cannot GET / page

查看:170
本文介绍了不能得到/页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用咕噜的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 =htt​​ps://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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆