Socket
Socket
Sign inDemoInstall

fetch-proxy_lib

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fetch-proxy_lib

[中文文档](#chinese-documents) [See development details](https://github.com/2234839/fetch-proxy)


Version published
Weekly downloads
7
Maintainers
1
Created
Weekly downloads
 

Readme

Source

中文文档 See development details

Overview

  • The fetch-proxy lib is a library for cross-domain requests
    • function in the same way as native fetch (npm package)
    • The main internal logic is as follows
      • if (the request target is in the same domain as the current page): use native fetch directly
      • else (in the context of a Grease Monkey script): use GM.xmlHttpRequest
      • else : call fetch-proxy service via native fetch

How to use the fetch-proxy lib

The github site has a CSP set up you can try the following script at my site

import { fetch_proxy } from "fetch-proxy_lib";

fetch_proxy(`https://zhihu.com`)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log("error", error));

中文文档

开发详情参见

概述

  • fetch-proxy lib 是一个用于跨域请求的库
    • 和 原生fetch 使用方式一样的函数 (npm package)
    • 内部主要逻辑如下
      • if (请求目标和当前网页是同一个域): 直接使用原生 fetch
      • else (处于油猴脚本的执行环境下): 使用 GM.xmlHttpRequest
      • else : 通过原生 fetch 调用 fetch-proxy service

fetch-proxy lib 的使用方式

github 网站设置了 CSP 可以去我的网站尝试下面的脚本

import { fetch_proxy } from "fetch-proxy_lib";

fetch_proxy(`https://zhihu.com`)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log("error", error));

Keywords

FAQs

Last updated on 08 May 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc