Closed jxyzn closed 5 years ago
Great! Could you please use following statement instead of modifying each interactor? You just need to put following call once in index.html
$.ajaxPrefilter(function( options ) { options.url = "http://localhost:3000/" + encodeURIComponent( options.url ); });
Later I will add more logic to automatically detect if localhost:3000 is up and then apply this policy so we do not have to touch it every time.
Ok, I removed the individual url modifications and inserted the ajaxPrefilter just after jquery loads. Doing the url mod via ajaxPrefilter results in the suffix-ed url becoming %-escaped, so the proxy script now unescapes the trailing part of the url before handling it.
I put together a little proxy script that, when prefixed on the API URLs, works as a rudimentary HTTP proxy that neuters the CORS headers so you don't need to turn them off in the browser. There's one new global (proxy_prefix) in index.html that is prepended to all the API URLs. If no proxy is to be used, set it to "".
The proxy script uses Mojolicious and can be run under Mojo with 'perl bling-proxy.pl daemon' or with the hypnotoad server/service with just 'hypnotoad bling-proxy.pl', then the index.html can be opened in Chrome with File > Open or by navigating directly to http://localhost:3000