Search code examples
network-programmingresourcescharles-proxy

Is there a way to serve a directory using map local and Charles?


I have a network request in the form of:

http://www.blahblah.com/folder/version/dist

I would like to add a rule to the Map Local option in Charles, in order to serve a directory that looks like:

Users/me/Documents/code/project/dist

The file structure of both dist folders are the same. My current request rule is: http://www.blahblah.com/folder/*/dist, and I'm asking it to serve Users/me/Documents/code/project/dist in its place, however, the files still come from the original requested resource.

Is there a way to proxy a whole directory?


Solution

  • You should be able to do so, by what is said in the CharlesProxy documentation:

    If you are testing css, swf or image changes you can map those file types to your local development copy of the website so you can browse the live site with all your development assets. Create a mapping from live.com/*.css to the root of your local development copy, and similar mappings for the other file types. Alternatively you can map whole directories or individual files as required.

    I guess your problem might be on the path where you are trying to map from. I would say you need to add an asterisk at the end of your path, something like:

    http://www.blahblah.com/folder/*/dist/*
    

    You can try to add the .css as done in the example

    http://www.blahblah.com/folder/*/dist/*.css