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

17 lines
415 B
JavaScript
Raw Normal View History

2021-02-18 16:57:52 -05:00
const PAGES = require('../../ui/constants/pages');
async function iframeDestroyerMiddleware(ctx, next) {
const {
request: { path },
} = ctx;
2021-02-19 09:30:28 -05:00
const decodedPath = decodeURIComponent(path);
2021-02-18 16:57:52 -05:00
2022-03-03 10:23:40 -05:00
if (!(decodedPath.startsWith(`/$/${PAGES.EMBED}`) || decodedPath.startsWith(`/$/api/content/v1/get`))) {
2021-02-18 16:57:52 -05:00
ctx.set('X-Frame-Options', 'DENY');
}
return next();
}
module.exports = iframeDestroyerMiddleware;