This project includes proxy servlets that can be used in conjunction with a Codename One Javascript application to provide CORS (cross-origin requests) support.
- Either download the .war distribution or build from source.
- Deploy the .war on your server.
- Configure your Codename One application to point to your proxy servlet.
$ git clone https://github.com/shannah/cors-proxy.git
$ cd cors-proxy
$ mvn package
Deploy the resulting .war file (located in the target directory) on your server.
Once you have deployed the .war file on your server, the servlet will be available http://example.com/yourwebapp/cn1-cors-proxy. The proxy takes a single GET parameter (_target) which specifies the URL that you wish to access. E.g. http://example.com/yourwebapp/cn1-cors-proxy?_target=http://www.codenameone.com.
There are two ways to "tell" your Codename One application about your proxy servlet.
- In your Java source :
Display.getInstance().setProperty("javascript.proxy.url", "http://example.com/yourwebapp/cn1-cors-proxy?_target=");
- In your index.html file.
<script>
window.cn1CORSProxyURL='http://example.com/yourwebapp/cn1-cors-proxy?_target=';
</script>
- Learn more about Codename One
- The CORSProxy class extends Smiley's HTTP Proxy
- The GAEProxyServlet class is adapted from this servlet which was developed by Mort Bay Consulting Pty. Ltd.
- This project developed and maintained by Steve Hannah
Apache 2.0 License