Created
February 22, 2023 16:22
-
-
Save dmitriyzyuzin/44c8057f87aad09868e398493b51287d to your computer and use it in GitHub Desktop.
Express server with adding HTTP headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const path = require('path'); | |
const app = express() | |
const PORT = process.env.port || 4000 | |
app.use((req, res, next) => { | |
res.setHeader('referrer-policy', 'strict-origin-when-cross-origin'); | |
next(); | |
}); | |
app.get('*', (req, res) => { | |
res.sendFile(path.resolve(__dirname, 'static/index.html')); | |
}); | |
app.listen(PORT, function () { | |
console.log(`Server works on PORT ${PORT}`) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You also need to create
static
folder and put there yourindex.html
file