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

URL PATH - [feature] #260

Open
davideareias1 opened this issue Jun 22, 2024 · 6 comments
Open

URL PATH - [feature] #260

davideareias1 opened this issue Jun 22, 2024 · 6 comments

Comments

@davideareias1
Copy link

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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
Copy link

MrMachi9 commented Jun 24, 2024 via email

@nfriedly
Copy link
Owner

nfriedly commented Jun 26, 2024

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
Copy link
Owner

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 #260 to stop those:

Unsubscribe

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

3 participants