U
U
Umid2017-01-22 18:28:02
Node.js
Umid, 2017-01-22 18:28:02

Is there a universal solution for headers?

Hello.
Wondering if there is a generic solution for
res.setHeader('Content-type', 'text/html; charset=utf-8');
I don’t know what header to put when requesting files (.css, .js, etc.), i.e. by default when accessing the server.
I put one, the second does not load.
The solution is needed on a vanilla node.
example in code
86fe8a66d1fc494a9fd0935026b25a69.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2017-01-22
@DarCKoder

Use it and don't be shy :)

const path = require('path');
app.use(express.static(path.join(__dirname, "static")));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question