节点js中的二级路由更改根目录

secondary level routing in node js changes root directory

在我的 web 项目中,我同时使用 angular JS 和 node JS。

为了在 Angular JS 中路由我的 url 我使用了下面的代码

app.config(function($routeProvider,$locationProvider) {
$routeProvider
.when("/expert/:expertname*", {
    templateUrl : "public/views/individual_expert.html",
    controller:"usercontroller"
})
.otherwise({
        redirectTo:"/home"
    })
    $locationProvider.html5Mode(true);
});

以上情况url生成如下,页面正常显示

http://localhost:3002/expert/58200b0f3574801df4ef767c

当我从浏览器使用相同的 url 刷新我的页面时,也会执行同样的操作,我会执行 NODE JS 代码。代码片段如下

app.get('/expert/:expertname',function(req,res){
    if(req.session.usersession!=null){
        if(req.session.usersession.type=="Member")
            res.sendfile('index/member_index.html');
        else if(req.session.usersession.type=="Expert")
            res.sendfile('index/expert_index.html');
        else if(req.session.usersession.type =="Admin")
            res.sendfile('index/admin_index.html');
        else
            res.sendfile('index/visitor_index.html');
    }
    else
        res.sendfile('index/visitor_index.html');
});

此时我在浏览器上看到的错误如下

1.) 我的所有 CSS 路径都已更改。

2.) 我的所有 JS 路径都已更改。

我注意到的是它正在用 "expert" 更改我的根目录并尝试搜索该目录中的所有导入。

我被困在这个问题上很久了。预先感谢您帮助我。

如果您没有正确理解我的问题,您可以发表评论。

在视图 html 页面中,有 /css/style.css 而不是正常的 css/style.css