From 6796320a2cfc061130d991fb0bedaf81a416c660 Mon Sep 17 00:00:00 2001 From: j-mendez Date: Tue, 25 Apr 2023 19:55:45 -0400 Subject: [PATCH] chore(fetch): add vercel edge support --- .circleci/config.yml | 7 ------- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ README.md | 2 -- package-lock.json | 4 ++-- package.json | 2 +- src/fetch.ts | 19 +++++++++++++++---- 6 files changed, 44 insertions(+), 16 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/build.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a9b9ba9..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,7 +0,0 @@ -orbs: - node: circleci/node@4.0 -version: 2.1 -workflows: - test: - jobs: - - node/test diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c3927cd --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build and test +on: [push] + +concurrency: + group: 'test' + cancel-in-progress: true + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: latest + + - name: Install dependencies + run: npm i + + - name: Test project + run: npm test \ No newline at end of file diff --git a/README.md b/README.md index 8b07cc8..7f465f8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # node-iframe -[![a11ywatch](https://circleci.com/gh/a11ywatch/node-iframe.svg?style=svg)](https://circleci.com/gh/a11ywatch/node-iframe) - create iframes to bypass security issues on your server with node.js can also be used in a browser ## Installation diff --git a/package-lock.json b/package-lock.json index 2ac9712..c22b2eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-iframe", - "version": "1.9.2", + "version": "1.9.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "node-iframe", - "version": "1.9.2", + "version": "1.9.4", "license": "MIT", "dependencies": { "cheerio": "^1.0.0-rc.3", diff --git a/package.json b/package.json index 00b8f1f..12d43bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-iframe", - "version": "1.9.2", + "version": "1.9.4", "description": "create iframes on your server to bypass CORS. Reverse engineer security issues.", "main": "dist/iframe.js", "scripts": { diff --git a/src/fetch.ts b/src/fetch.ts index 21787d1..3aa577d 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -6,10 +6,21 @@ if (!fetcher) { (async () => { if (process) { - const followRedirects = require('follow-redirects'); - followRedirects.maxRedirects = 4; - const http = followRedirects.http; - const https = followRedirects.https; + let http; + let https; + + // add edge non streaming support + if(process.env.VERCEL_EDGE) { + http = require("http") + https = require("https") + } else { + const followRedirects = require('follow-redirects'); + + followRedirects.maxRedirects = 4; + + http = followRedirects.http; + https = followRedirects.https; + } const getHttp = (url: string) => url.startsWith("https://") ? https : http;