Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

frameguard

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frameguard

Middleware to set X-Frame-Options headers

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is frameguard?

The frameguard npm package is used to help secure your web applications by setting the X-Frame-Options header. This header is used to control whether a browser should be allowed to render a page in a <frame>, <iframe>, <embed>, or <object>. This can help prevent clickjacking attacks.

What are frameguard's main functionalities?

Deny

This feature sets the X-Frame-Options header to 'DENY', which means the page cannot be displayed in a frame, regardless of the site attempting to do so.

const frameguard = require('frameguard');
const express = require('express');
const app = express();

app.use(frameguard({ action: 'deny' }));

app.get('/', (req, res) => {
  res.send('X-Frame-Options set to DENY');
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

SameOrigin

This feature sets the X-Frame-Options header to 'SAMEORIGIN', which means the page can only be displayed in a frame on the same origin as the page itself.

const frameguard = require('frameguard');
const express = require('express');
const app = express();

app.use(frameguard({ action: 'sameorigin' }));

app.get('/', (req, res) => {
  res.send('X-Frame-Options set to SAMEORIGIN');
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

AllowFrom

This feature sets the X-Frame-Options header to 'ALLOW-FROM https://example.com', which means the page can only be displayed in a frame on the specified origin.

const frameguard = require('frameguard');
const express = require('express');
const app = express();

app.use(frameguard({ action: 'allow-from', domain: 'https://example.com' }));

app.get('/', (req, res) => {
  res.send('X-Frame-Options set to ALLOW-FROM https://example.com');
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

Other packages similar to frameguard

Keywords

FAQs

Package last updated on 29 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc