Layer 2 routing in node js changes root directory

In my web project, I use angular JS and node JS at the same time.

To route my url in Angular JS I used the code below

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

In the above example, the generated url looks like this and the page renders correctly.

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

The same thing is done when I refresh my page with the same URL from the browser as my NODE JS runs. Code snippet below

 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'); }); 

At this time, the errors that I see in my browser are as follows

1.) All my CSS paths have been changed.

2.) All my JS paths are changed.

What I noticed was that he changed the root directory with the help of an "expert" and tried to find all the imports in this directory.

I am stuck with this for a long time. Thank you in advance for your help.

You can comment if you do not receive my question correctly.

+6
source share
1 answer

on the html view page, <<20> instead of css/style.css

+1
source

Source: https://habr.com/ru/post/1012140/


All Articles