lbry-desktop/web/middleware/iframe-destroyer.js

17 lines
362 B
JavaScript
Raw Permalink Normal View History

2021-02-18 22:57:52 +01:00
const PAGES = require('../../ui/constants/pages');
async function iframeDestroyerMiddleware(ctx, next) {
const {
request: { path },
} = ctx;
2021-02-19 15:30:28 +01:00
const decodedPath = decodeURIComponent(path);
2021-02-18 22:57:52 +01:00
2021-02-19 15:30:28 +01:00
if (!decodedPath.startsWith(`/$/${PAGES.EMBED}`)) {
2021-02-18 22:57:52 +01:00
ctx.set('X-Frame-Options', 'DENY');
}
return next();
}
module.exports = iframeDestroyerMiddleware;