twitchax / AspNetCore.Proxy

ASP.NET Core Proxies made easy.
MIT License
505 stars 80 forks source link

change a js file content #116

Open MansoorJafari9 opened 2 weeks ago

MansoorJafari9 commented 2 weeks ago

Hi @twitchax

How can I change content a js file and load proxy url I mean when user open https://example.com and I proxy him to https://example2.com How can I change a js file in https://example2.com

Thanks

twitchax commented 2 weeks ago

Hello! You will need to use the WithAfterReceive hook. Essentially, you have access to the entire proxied response before it goes back down to the client. You can edit any part of the headers or content as you wish.

From the README:

.WithAfterReceive((c, hrm) =>
        {
            // Alter the content in  some way before sending back to client.
            var newContent = new StringContent("It's all greek...er, Latin...to me!");
            hrm.Content = newContent;

            return Task.CompletedTask;
        })