Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cors-proxy can be replace by simple nginx configuration #1746

Open
Zorin95670 opened this issue Mar 16, 2023 · 1 comment
Open

Cors-proxy can be replace by simple nginx configuration #1746

Zorin95670 opened this issue Mar 16, 2023 · 1 comment

Comments

@Zorin95670
Copy link

Hi,

We use this library, for our open source project. And we find a way to not use cors-proxy, because they are SVE on some dependencies.

After investiguation and test, there is the nginx config that do the job :)

nginx.conf

events {
}

http {

  include /etc/nginx/mime.types;
  sendfile on;

  server {
    listen 80;
    listen [::]:80;

    location "/cors-proxy/" {
      resolver 8.8.8.8;
      proxy_hide_header WWW-Authenticate;
      rewrite ^/cors-proxy/(.*)$ $1 break;
      proxy_pass "https://$uri$is_args$args";
    }

    # not for cors-proxy but only to serve all css/js file
    location ~ \*.css {
      add_header  Content-Type    text/css;
    }

    location ~ \*.js {
      add_header  Content-Type    application/x-javascript;
    }

    location / {
      root /usr/share/nginx/html;
    }
  }
}

and the proxy configuration for the js code, exemple with git.clone:

git.clone({
    fs,
    http,
    url
    dir,
    onAuth: () => ({
      (...)
    }),
    corsProxy: '/cors-proxy',
    (...)
  }).then(() => saveProject(project));
@jcubic
Copy link
Contributor

jcubic commented Mar 16, 2023

Note that this is also a CORS Proxy. I personally use one created in PHP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants