@rhildred/cors-proxy2

1.0.9 • Public • Published

cors-proxy2

Cloudflare worker to run with Stackblitz.com and github.com.

To use:

npm install --save-dev @rhildred/cors-proxy2

put the url in the query string. For instance:

        const res = await request(app)
        .get("/proxy?url=https://github.com/diy-pwa/diy-pwa/archive/refs/heads/main.zip");

Consume in cloudflare pages function. For instance in functions/corsproxy/[[corsproxy]].js:

import { CorsProxyResponse } from '@rhildred/cors-proxy2';

export async function onRequest(context){
    return CorsProxyResponse.fetch(context.request, context.env);
}

or as a worker I think

import { CorsProxyResponse } from '@rhildred/cors-proxy2';
export { CorsProxyResponse as default };

This code is based on the cors-proxy code from isomorphic-git. It is refactored to be exposed as a cloudflare worker or pages function.

I am consuming the cloudflare pages function in diy-pwa and git-pwa. These projects are for a stackblitz development environment for sales engineers to make progressive web apps. The pwa is for hosting .svg configuration models and complements for business to business products.

Package Sidebar

Install

npm i @rhildred/cors-proxy2

Weekly Downloads

4

Version

1.0.9

License

MIT

Unpacked Size

8.55 kB

Total Files

5

Last publish

Collaborators

  • rhildred