Open mattbenton opened 4 years ago
@mattbenton Thank you for the detailed report π
I understand your situation, I'd suggest:
Thanks for the quick response!
For simple CORS use cases, adding a response header of Access-Control-Allow-Origin: *
may be sufficient. That is something you could consider for the convenience option you proposed.
However, in my specific scenario I will still need to use scripting because our app sends credentials with CORS requests. When credentials (cookies) are sent, the browser does not allow wildcard *
origins to be used and you must reply with a specific origin value, e.g. https://domain1.com
. For my use case, I am mapping content that is used across multiple domains so I need to use scripting to dynamically set the Access-Control-Allow-Origin
response header to the origin/domain making the request.
Thanks for the hint π. I'm on it now and I will send you a hotfix today π
@mattbenton Please check out this build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.5.2_Fix_JWT_Addon.Fix+MIME.Support_MapLocal_Scripting.dmg
This build will run the Script Tool after Map Local as you expected π
Setup Scripting (Right-click on the flow -> It will create automatically) and add some HTTP Headers on the Response
function onResponse(context, url, request, response) {
// console.log(response);
// Update or Add a new header
response.headers["Access-Control-Allow-Origin"] = "*";
// Done
return response;
}
@NghiaTranUIT This is great! Works exactly as I'd hoped.
I also like the X-Proxyman-*
headers. It makes configurations easier to debug.
Thanks for the quick turnaround π
I'll be suggesting this tool to my colleagues.
Glad to hear that π I will roll out the release in the week π
@NghiaTranUIT And what about remote map?
@NghiaTranUIT yes, scripting after map remote is still actual π₯²
@ldraminski @mattbenton looks like I should support: Map Remote -> Scripting
Let me implement it and send you guys a Beta build π
@mattbenton @ldraminski can you try this Beta build: https://download.proxyman.io/beta/Proxyman_4.15.0_Map_Remote_Then_Scripting.dmg
Here is how to setup:
Let me know if you have find some bugs/issued π
@NghiaTranUIT thank you so much! This is what I need π Everything is okey
@NghiaTranUIT Hi, does the latest Proxyman, which is 4.16.0 also have this function (using map remote with scripting simultaneously)?
@linkjane yes, it's included in the latest build v4.16.0
Proxyman version?
2.5.2 (20520)
macOS Version?
10.15.6 (19G2021)
Feature Request
Allow "Map Local" and "Map Remote" features to work with "Scripting" for the same request.
Current Behavior
When Scripting is enabled for the same request as Map Local, Map Local is ignored.
Expected Behavior
It would be great if Map Local can run first to replace the body of the response.
After this, additional Scripting can be used to further modify the response body or headers.
Example use case
I am trying to use Map Local to map an entire directory to test changes before deploying changes to an app online. Map Local causes all CORS headers to be lost. (Note, the same thing happens in Charles Proxy).
I was hoping I would be able to use the Scripting feature to modify the headers in the response to allow CORS again after the mapping has run.
In Charles Proxy I was able to use the Map Local and "Rewrite" features at the same time to achieve this, though it was quite convoluted to achieve. So far it is impossible to achieve in Proxyman.
By the way, thank you for your work on this awesome tool. I first noticed this tool a month ago and I purchased a license as soon as you released the scripting feature. I believe allowing scripting to work with mapping would make tool even more attractive.