{"id":18991590,"url":"https://github.com/alex2844/js-global-fetch","last_synced_at":"2026-05-13T13:49:06.661Z","repository":{"id":57096319,"uuid":"248143241","full_name":"alex2844/js-global-fetch","owner":"alex2844","description":"Universal Fetch API, FormData, AbortController, CorsProxy for Nodejs, Browsers and Google Apps Script","archived":false,"fork":false,"pushed_at":"2021-10-15T10:26:49.000Z","size":84,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T18:03:09.565Z","etag":null,"topics":["corsproxy","fetch","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alex2844.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-18T05:06:24.000Z","updated_at":"2022-01-10T15:19:45.000Z","dependencies_parsed_at":"2022-08-22T21:41:12.839Z","dependency_job_id":null,"html_url":"https://github.com/alex2844/js-global-fetch","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":"alex2844/template_release","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex2844%2Fjs-global-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex2844%2Fjs-global-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex2844%2Fjs-global-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alex2844%2Fjs-global-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alex2844","download_url":"https://codeload.github.com/alex2844/js-global-fetch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240002675,"owners_count":19732242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["corsproxy","fetch","nodejs"],"created_at":"2024-11-08T17:14:18.840Z","updated_at":"2026-04-14T12:30:19.042Z","avatar_url":"https://github.com/alex2844.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# globalFetch\n\n[![Version](https://img.shields.io/npm/v/js-global-fetch.svg)](https://www.npmjs.org/package/js-global-fetch) [![Extension](https://www.google.com/images/icons/product/chrome_web_store-32.png)](https://alex2844.github.io/js-global-fetch/index.html?extension)\n\n## Universal Fetch API, FormData, AbortController, CorsProxy for Nodejs, Browsers and Google Apps Script\n\n#### Install\n###### nodejs\n``` bash\nnpm install js-global-fetch\n```\n###### cdn\n``` html\n\u003cscript src=\"https://alex2844.github.io/js-global-fetch/dist/polyfill.js\"\u003e\u003c/script\u003e\n```\n###### Google Apps Script (https://github.com/alex2844/js-global-fetch/blob/master/GAS.md)\n###### extension\n- chrome://extensions/\n- Dev mode on\n- 'Load unpacked extension' button and select the unzipped folder for your extension to install it.\n\n#### Usage\n###### Get json\n``` javascript\nconst { fetch } = require('js-global-fetch');\nfetch('https://httpbin.org/get', {\n\theaders: {\n\t\t'Cors-Cache': 60*60*24*1000,\n\t\t'Cors-Referer': 'https://alex2844.github.io/js-global-fetch/',\n\t\t'Cors-User-Agent': 'globalFetch'\n\t}\n})\n.then(res =\u003e res.json())\n.then(body =\u003e console.log(body));\n```\n###### CorsProxy as a plugin for Fastify\n``` javascript\nconst\n\tFastify = require('fastify'),\n\t{ CorsProxy } = require('js-global-fetch');\n(Fastify()\n\t.register(CorsProxy, { prefix: '/proxy' }) // http://localhost:3000/proxy/\n\t.get('/', async (req, rep) =\u003e 'Index page') // http://localhost:3000/\n\t.listen(3000, () =\u003e console.log('Server start'))\n);\n```\n###### Get iframe content\n``` html\n\u003ciframe src=\"https://httpbin.org/get\" frameborder=\"0\" allowfullscreen=\"true\" width=\"500\" height=\"300\" loading=\"lazy\"\u003e\u003c/iframe\u003e\n\u003cscript\u003e\n\t$('iframe').addEventListener('load', event =\u003e {\n\t\t// console.log(event.target.contentWindow.document.body.innerHTML); // Blocked a frame with origin \"http://localhost:8080\" from accessing a cross-origin frame.\n\t\tnew Promise(res =\u003e {\n\t\t\tlet onmessage = e_ =\u003e {\n\t\t\t\tif (e_.data.corsProxy \u0026\u0026 (event.timeStamp == e_.data.timeStamp)) {\n\t\t\t\t\twindow.removeEventListener('message', onmessage, false);\n\t\t\t\t\treturn res(e_.data._corsProxy_);\n\t\t\t\t}\n\t\t\t}\n\t\t\tevent.target.contentWindow.postMessage({\n\t\t\t\tcorsProxy: {\n\t\t\t\t\teval: (() =\u003e document.body.innerHTML).toString()\n\t\t\t\t},\n\t\t\t\ttimeStamp: event.timeStamp\n\t\t\t}, '*');\n\t\t\twindow.addEventListener('message', onmessage, false);\n\t\t}).then(html =\u003e {\n\t\t\tconsole.log(JSON.parse(html.replace(/^(.*?)\u003e/, '').replace(/\u003c(.*?)$/, '')));\n\t\t});\n\t}, { once: true });\n\u003c/script\u003e\n```\n###### Open \"Youtube on TV\"\nhttps://www.youtube.com/tv?corsProxy={%22user-agent%22:%22Mozilla/%20Chrome/%20Mobile%20Safari/;%20SMART-TV%22}\n\n#### Run cli\n``` bash\nPORT=3000 globalFetch\n```\n\n#### Demo and tests\nhttps://alex2844.github.io/js-global-fetch/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex2844%2Fjs-global-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falex2844%2Fjs-global-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falex2844%2Fjs-global-fetch/lists"}