Reputation: 300
I'm trying to serve an Angular project using lite-server. The server responds with a 404 whenever a file in assets folder is requested. I have created a bs-config.json and setting the routes option didn't work.
Here is my directory structure
node_modules/ src/ ..app/ ....index.html ..assets/ ....img/ ..config/ ....bs-config.json
bs-config.json
{
"port": 8000,
"files": ["../src/**/*.{html,htm,css,js}"],
"server": {
"baseDir": ["./src/app", "./"],
"routes": {
"/assets": "../assets"
}
}
}
How I try to load the files. (index.html)
<img src="assets/img/image.png">
Upvotes: 3
Views: 1114
Reputation: 7986
I had a similar problem but needed a resource at an absolute path not a relative one.
I needed something like <img src="/assets/img/image.png">
and sovled it with a bs-config.json like
{
"port": 8000,
"files": ["../src/**/*.{html,htm,css,js}"],
"server": {
"baseDir": ["./src/app", "./"
"./src" ///<----------Added this item
],
}
}
But I tried this with a relative URL and it didn't work.
I could see the URL requested by the browser in the lite-server log output so maybe you can check that and work from there?
Upvotes: 7