简体   繁体   中英

Expressjs: Relative links in subfolder serving from route

This is driving me crazy. I don't know if it's something simple or not but I feel like it should work. I am routing subdirectory requests to an app:

app.use('/admin', express.static(__dirname + '/webapps/admin'));

In webapps/admin/index.html I have this:

<link href="styles/vendor.3b7af2c7.css" rel="stylesheet">

Which makes sense because the file is in /webapps/admin/styles

But then I get this:

"NetworkError: 404 Not Found - https://www.domain.com/styles/vendor.3b7af2c7.css"

Why is it dropping down to the root for this relative link? How do I make it read relative properly? Thanks.

I found the problem. I was told to do something specific in Angular that required that I add <base href="/" /> to the element. This broke it.

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