简体   繁体   中英

NodeJS Express Routing With Multiple URI/URL

I have a public folder inside my app which contains the HTML/CSS3/JS code.It has 2 part to it. One contains the public facing index.html inside public/web and another is the admin view which contain is only for admins. Below is the basic layout

public
     -->admins-->app/index.html
     -->web-->multi-page-layout-->webuild/index.html



app.use('/admin/login/system', gzippo.staticGzip("public/admins/app"));
app.use('/', gzippo.staticGzip('public/web/multi-page-layout/webuild'));

My problem is the base route / works as expected. but when I access /admin/login/system the page throws an error as CSS/JS files linked using script and link are not found.

Below is one of the error message generated in console

 http://localhost:5001/admin/login/plugins/moment.min.js

Attached screenshot for reference在此处输入图像描述

How can I create route so that I can access these pages and the pages should work fine and expected. Please note all are AngularJS app in different folder and using EJS is not feasible.

How can I fix the route so that the route /admin/login/system is loaded and so is its reference files from its index.html

Attaching reference of my folder structure

在此处输入图像描述

One way is to configure your server to serve your Angular app entry point. So you have one server defined route and since you are using Angular, client-side routing should kick in for navigating to other pages(this is assuming you have such routings implemented in your angular app and your app is an SPA)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM