Issue
I'm new into AngularJS project in .NET 6.0 or Core. I just put a images into a folder like wwwroot/imgs
Then images are called from a custom static css referenced in: angular.json
like:
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css",
"src/css/main.css"
],
and then in main.css for example:
body {
background: #fff9ee;
background: url(/imgs/bg11.webp) repeat;
}
but the resource https://localhost:port/imgs/bg11.webp
returns 404
The css loads fine.
Also I'm using
app.UseStaticFiles();
in Program.cs
Also I check the "Copy Always"
and "Build Action: Content"
UPDATE:
Problem also in index.html
with a GIF
file:
<img class="img-fluid" src="/imgs/1.gif" alt="">
Tried with:
.UseStaticFiles(new StaticFileOptions
{
ServeUnknownFileTypes = true,
})
neither works.
Thanks in advance for help.
Solution
Finally I discover the problem. In development the project works through a reverse proxy, so we need to configure every folder in the file proxy.conf.js
in order to the proxy let the project serve the static files.
For example, to add /imgs
files in my case:
const PROXY_CONFIG = [
{
context: [
"/weatherforecast",
"/imgs"
],
Answered By - Leandro Bardelli
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.