Skip to content

Instantly share code, notes, and snippets.

@dmitriyzyuzin
Created February 22, 2023 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitriyzyuzin/44c8057f87aad09868e398493b51287d to your computer and use it in GitHub Desktop.
Save dmitriyzyuzin/44c8057f87aad09868e398493b51287d to your computer and use it in GitHub Desktop.
Express server with adding HTTP headers
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}`)
});
@dmitriyzyuzin
Copy link
Author

You also need to create static folder and put there your index.html file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment