T
T
Torento203452021-06-08 23:54:27
Express.js
Torento20345, 2021-06-08 23:54:27

How to specify the path of static files and process them on the server?

There is a
-static
folder There is a
-server folder There is a -pages
folder Path to pages is specified Output file = fs.readFileSync(path.join(__dirname, '../../pages/') + 'index.html', 'utf8 '); The server returns index.html, but does not return styles and images Although there is a code above

path.join(__dirname, '../../pages/');

app.use(express.static(path.join(__dirname, '../../static/')));

The path is specified in index.html
<img src="/public/img/images/po.png">

And the file with the server is located in the folder server

Tell me, how can I configure the return of static files?
Taking into account that in pages there will be more folders with other pages

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question