nfriedly / node-unblocker

Web proxy for evading internet censorship, and general-purpose Node.js library for proxying and rewriting remote webpages
https://www.npmjs.com/package/unblocker
GNU Affero General Public License v3.0
454 stars 880 forks source link

URL PATH - [feature] #260

Open davideareias1 opened 3 months ago

davideareias1 commented 3 months ago

Hi, i have been experimenting with this package and it's really good.

The only issue im having is that there is no default url option.

For example in order to work the url should look like this: http://localhost:8080/proxy/https://www.youtube.com/watch?v=dQw4w9WgXcQ

but if we specified something like default_url: "https://www.youtube.com/" then the proxy could handle the url like this: http://localhost:8080/proxy/watch?v=dQw4w9WgXcQ

I'm not sure how hard this would be to implement, but this would be game changer for my project.

Thank you for your attention!

nfriedly commented 3 months ago

Oh, that's an interesting idea.

However, it might be pretty difficult to implement. The way the proxy is built, it uses the URL path pretty heavily to determine where to load other assets from, and it has logic to figure out the correct URL when something is missing the domain portion. Having a default URL would interfere with that recovery logic.

That said, for youtube specifically, you could just about use the YouTube example without the proxy - just wire it up to a plain node js server and add your own logic to handle the URL.

davideareias1 commented 3 months ago

Hey, thanks for the reply.

At the moment im trying to run 2 servers

  1. server is the youtube example
  2. server is an iframe to the 1st server

This way i could implement some logic behind server 2 to show the currect url.

The problem is that im having a bunch of issues with cors the iframe cannot access the server 1 without breaking the unblocker middleware.

i tried to change the cors policy like this:

app.use(function (req, res, next) {
  // Website you wish to allow to connect
  res.setHeader('Access-Control-Allow-Origin', '*');

  next();
});

app.use(
  unblocker({
    responseMiddleware: middlewareFunctions,
    prefix: '/store/'
  })
);
davideareias1 commented 3 months ago

I found a simple fix.

in the file proxy.js after line 70 when you do:

    data.headers = _.cloneDeep(data.remoteResponse.headers);

i added after


    data.headers['access-control-allow-origin'] = '*';
    data.headers['x-frame-options'] = 'ALLOW-FROM *';
MrMachi9 commented 3 months ago

I'm so confused who are you guys

On Sat, Jun 22, 2024, 10:05 PM Davide Areias @.***> wrote:

I found a simple fix.

in the file proxy.js after line 70 when you do:

data.headers = _.cloneDeep(data.remoteResponse.headers);

i added after

data.headers['access-control-allow-origin'] = '*';
data.headers['x-frame-options'] = 'ALLOW-FROM *';

— Reply to this email directly, view it on GitHub https://github.com/nfriedly/node-unblocker/issues/260#issuecomment-2184342289, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATRP5YNP7QMPVRXDG7NX4O3ZIYUNXAVCNFSM6AAAAABJXY5YFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBUGM2DEMRYHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

nfriedly commented 3 months ago

Hi @MrMachi9,

I created node unblocker, and davideareias1 is trying to use it.

I'm guessing somewhere along the line you hit the Watch button for node unblocker and set it to notify you of all activity on this project. The project doesn't get a ton of activity, so it may have been a while ago. If that's the case, then there should be an Unwatch button you can click on the upper-right-ish part of https://github.com/nfriedly/node-unblocker (You may have to log in first to see it.)

It should look like this, although maybe with the icons aligned correctly:

Unwatch

Click it and you'll stop getting all these emails.

nfriedly commented 3 months ago

Oh, and you might still get emails from this thread because you've now commented here. Click the Unsubscribe button on the left side of https://github.com/nfriedly/node-unblocker/issues/260 to stop those:

Unsubscribe