3 const env = require('gitter-web-env');
4 const config = env.config;
6 // Only allow iframe embedding from within Gitter
7 function preventClickjackingOnlyGitterEmbedMiddleware(req, res, next) {
8 // `sameorigin` does not work here because the desktop app has a root origin of `chrome-extension://` and will be blocked
9 res.set('X-Frame-Options', `allow-from ${config.get('web:basepath')}`);
10 // Because Chrome does not support `X-Frame-Options: allow-from <uri>` syntax above, we also have a CSP setup
11 res.set('Content-Security-Policy', `frame-ancestors 'self' ${config.get('web:basepath')}`);
16 module.exports = preventClickjackingOnlyGitterEmbedMiddleware;