I am trying to make a proxy server that loads external websites under my domain. My goal with this is to let people visit myDomain.com/anyDomain.com and be able to use anyDomain.com with added functionality (injected JS).
I tried using the Request package to get the html of the site and then send it to the response in Express, but this approach messes up the site (relative paths, missing CSS, bad JS requests, etc).
Is there any node package that accomplishes this task? If not, how can I do it myself?
Thank you!
This should get you started, it allows you to call fx
http://localhost:6008/www.example.com/hello/world?foo=barwhich would then proxyhttp://www.example.com/hello/world?foo=barbut if you are going to proxy other webpages you are going to hit all sorts of problems.First of the fact that it might not be legal. I am not aware of the rules round proxying pages and altering them, you should check the laws regarding your specific use-case.
Secondly, since a lot of content on webpages are using absolute urls (especially if the content uses multiple domains for things like CDN and APIs), these resources are still going to point back to the original destination, which might very well cause quite a few headaches