I want to proxy foo.com/some/path/<somepath> to bar.com/<somepath> on my web application.
So when the user enters foo.com/some/path/example.html he will get the content my backend fetches from bar.com/example.html. But when the browser renders the HTML on foo.com/some/path/example.html - for example we have a <link rel="stylesheet" href="/main.css">, I want it to fetch bar.com/some/path/main.css but as it is - the browser fetches bar.com/main.css.
Important note: I can't edit the content on bar.com/<somepath>.
How can I change the base url it fetches from? (On the same origin)
Asked
Active
Viewed 126 times
0
Uri
- 31
- 6
-
Can you change your proxy to rewrite URLs on the fly? – Evert Aug 17 '22 at 00:22
-
What you describe is actually a "reverse proxy." Which tool are you using to implement it? It will depend on the functionality of your reverse proxy software. Apache can do it, look at this example: https://stackoverflow.com/questions/14431090/proxyhtml-to-rewrite-url – Stephen Ostermiller Aug 17 '22 at 07:41
-
I build my own proxy in NodeJS using `node-fetch`, I can do anything on the fly. What can I do? – Uri Aug 17 '22 at 08:34