This is a simple proxy server that adds the necessary headers to allow Cross-Origin Resource Sharing (CORS) for a specified website.
These instructions will help get a copy of the CORS-Proxy up and running on a local machine for development and testing purposes.
Node.js and npm are required for the proxy to run. They can downloaded from the official website or can be installed with a package manager like Homebrew (for macOS) or Chocolatey (for Windows).
- Clone or download this repository.
- Open a terminal and navigate to the root directory of the project.
- Run
npm install
to install the required dependencies.
Run the following command to start the proxy server:
node index
The server will listen on port 3000 by default. To use a different port, pass the port as a parameter.
For example, to run the proxy server on port 3333, run the following command:
node index 3333
To use the proxy, simply make a request to localhost:<port>/proxy
with the target URL as a header named 'Target-URL'. For example, to make a GET request to https://example.com/api/users, use the following URL:
http://localhost:3000/proxy/api/users
With the following header:
{ 'Target-URL': 'https://example.com' }
If using during development, a default URL can be set to avoid having to set the Target-URL header with every request.
For example, to set https://example.com/ as the default URL, pass the target URL as a parameter in the terminal:
node index 3000 https://example.com/
Note: if a Target-URL header is present in the request, it will override the default URL.
- The proxy only supports HTTP and HTTPS requests.
- The proxy does not support websockets.
- The proxy does not support server-side rendering of client-side applications.
If you find a bug or have an idea for a new feature, please open an issue or submit a pull request.