Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shannah/cors-proxy
Proxy servlet that adds Allow-Origin headers to allow for CORS
https://github.com/shannah/cors-proxy
Last synced: 2 months ago
JSON representation
Proxy servlet that adds Allow-Origin headers to allow for CORS
- Host: GitHub
- URL: https://github.com/shannah/cors-proxy
- Owner: shannah
- Created: 2015-04-15T23:02:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-14T18:16:25.000Z (almost 8 years ago)
- Last Synced: 2023-04-01T05:43:28.579Z (almost 2 years ago)
- Language: Java
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Codename One CORS Proxy
This project includes proxy servlets that can be used in conjunction with a Codename One Javascript application to provide CORS (cross-origin requests) support.
## Getting Started
1. Either [download the .war distribution](https://github.com/shannah/cors-proxy/releases) or build from source.
2. Deploy the .war on your server.
3. [Configure your Codename One application](#configuring-your-codename-one-application) to point to your proxy servlet.### Building from Source
~~~~
$ 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.
### Testing the Proxy
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`.
### Configuring Your Codename One Application
There are two ways to "tell" your Codename One application about your proxy servlet.
1. In your Java source :
~~~~
Display.getInstance().setProperty("javascript.proxy.url", "http://example.com/yourwebapp/cn1-cors-proxy?_target=");
~~~~
2. In your index.html file.
~~~~
window.cn1CORSProxyURL='http://example.com/yourwebapp/cn1-cors-proxy?_target=';
~~~~# Advanced
1. [Deploying on AppEngine](https://github.com/shannah/cors-proxy/wiki/Deploying-on-App-Engine)
2. [Embedding Servlet into Existing Project](https://github.com/shannah/cors-proxy/wiki/Embedding-Servlet-into-Existing-Project)# Learn More
1. Learn more about [Codename One](http://www.codenameone.com)
# Credits
1. The CORSProxy class extends [Smiley's HTTP Proxy](https://github.com/mitre/HTTP-Proxy-Servlet)
2. The GAEProxyServlet class is adapted from [this servlet](http://www.javased.com/?source_dir=http-testing-harness/server-provider/src/main/java/org/sonatype/tests/http/server/jetty/impl/ProxyServlet.java) which was developed by Mort Bay Consulting Pty. Ltd.
3. This project developed and maintained by [Steve Hannah](http://sjhannah.com)# License
Apache 2.0 License