Why is my html file not loading using express.static?

File structure:

- simulated-selves
  - client
    - directives
      - Statement
        - statement.directive.html
  - lib
  - server
    - app.js
  - index.html

I have:

app.use(express.static('client'));
app.use(express.static('lib'));

My resources uploaded to index.htmlare loading properly.

<link rel='stylesheet' href='assets/app.css' />
<script src='angular.js'></script>
<script src='app.js'></script>
<script src='controllers/main.controller.js'></script>
<script src='directives/Statement/statement.directive.js'></script>
<script src='providers/statement.factory.js'></script>

But I get this error:

enter image description here

Why is this? statement.directive.htmlnested in the folder clientto which it applies express.static. I know that it is not invested directly under client, but not one of my other assets is loading properly. The only difference I see is using <script>/ <link/>as compared to the HTTP request. If this is a problem, I’m not sure how to get around this other than creating an endpoint for each asset, which seems very excessive.

: lib express.static? , . , , GET .

EDIT: png . client > assets > images.

+2
1

: app.use(express.static('client'));.

- app.use . , , , .

, express.static('client'). :

/foo/bar.ext, , /client/foo/bar.ext. , . , .

/client/directives/Statement/statement.directive.html

, ,

/client/client/directives/Statement/statement.directive.html

, , . , , . ,

/directives/Statement/statement.directive.html

libs express.static:

, libs

- Chev

0

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


All Articles