1.10.0 • Published 3 months ago

node-iframe v1.10.0

Weekly downloads
108
License
MIT
Repository
github
Last release
3 months ago

node-iframe

create iframes to bypass security issues on your server with node.js can also be used in a browser

Installation

npm install node-iframe

How to use

as express middleware

import createIframe from "node-iframe";

app.use(createIframe);

app.get("/iframe", (req, res) => {
  res.createIframe({
    url: req.query.url,
    baseHref: req.query.baseHref, // optional: determine how to control link redirects,
    config: { cors: { script: true } }, // optional: determine element cors or inlining #shape src/iframe.ts#L34
  });
});

On the client use directly in your iframe if your api is on the same server set the url below like this or if your using a framework like gatsby, nextjs, etc or non-express apps

<iframe src="/iframe/?url=https://www.etsy.com" />

You can even fetch the iframe directly by importing fetchFrame on the client or server. Set safeMode=true in conjunction with inline scripts to add error handling.

import { fetchFrame } from "node-iframe";

async function fetchIframe() {
  return await fetchFrame({ url: "https://www.etsy.com", safeMode: false });
}

Configure how to handle resources for all request

const { configureResourceControl, configureTemplates } = require("node-iframe");

// optional: configure if elements should be inlined, cors, etc, this combines with the `config` param
configureResourceControl({
  inline: { script: true, link: false },
  cors: { script: true },
});
// optional: configure error-pages - check src/templates for more info
// 0: error, 1: not-found, 2: all templates - check src/templates/config for options
configureTemplates("<div>No Fish found</div>", 1);

Example

License

MIT

1.10.0

3 months ago

1.9.4

1 year ago

1.9.2

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.9

1 year ago

1.8.8

1 year ago

1.8.7

1 year ago

1.8.6

1 year ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.5

2 years ago

1.7.4

2 years ago

1.7.3

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.8.5

2 years ago

1.8.4

2 years ago

1.8.3

2 years ago

1.6.4

2 years ago

1.6.3

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.7.0

2 years ago

1.5.9

4 years ago

1.5.10

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.5.0

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.4

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.9

4 years ago

1.1.10

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago