I write website prototypes that use data from a server I do not control, the response is in JSON and the server does not support JSONP, thus I have problems with CORS as I am developing in the client only.
I have managed to get around this by running a local apache HTTP webserver with the following ProxyPass rules in my vhosts.conf
ProxyPass /api/de/ http://de.test.com/api/
ProxyPassReverse /api/de/ http://de.test.com/api/
ProxyPass /api/jp/ http://jp.test.com/api/
ProxyPassReverse /api/jp/ http://jp.test.com/api/
ProxyPass /api/ru/ http://ru.test.com/api/
ProxyPassReverse /api/ru/ http://ru.test.com/api/
ProxyPass /api/uk/ http://uk.test.com/api/
ProxyPassReverse /api/uk/ http://uk.test.com/api/
As you can see there are multiple subdomains for the same domain, each one is for accessing a different locale, in real terms this means I get the data in a different language, which is important for my prototypes.
There are more than 30 languages that I would like the ability to test in my prototypes and I want to know if there is a way to write my ProxyPass rules dynamically (or a better solution).
I'm using jQuery with the getJSON method and an example of the URL I am hitting is as follows
url = '/api/'+pos+'/data.html?destination=...
Where pos is simply a string I pass through with 'de', 'jp', 'ru', or 'uk'