0.0
No release in over a year
The gem in development is part of a suite of Developer Productivity Software that is strategically designed to enhance efficiency and productivity during the Software Development Life Cycle (SDLC). It mainly addresses the limitations and blockades encountered due to Cross-Origin Resource Sharing (CORS) policies that often hinder smooth interaction between the frontend and backend components when hosted on different domains.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.21.0
~> 3.1.0
 Project Readme
Simple Proxy Logo

Simple Proxy

License: MIT Downloads Documentation

Simple Proxy is a lightweight and easy-to-use proxy server built with Ruby, Sinatra, and HTTParty. It's designed to forward requests to specified target URLs, making it a versatile tool for developers working with APIs and web services.

Features

  • Supports GET, POST, and PUT HTTP methods.
  • Supports Cross-Origin Resource Sharing (CORS) with Sinatra::CrossOrigin.
  • Transfers headers and parameters to the target URL.
  • Provides mechanisms for starting and stopping the server.

Installation

To install Simple Proxy, you can add this line to your application's Gemfile:

gem 'simple_proxy'

and then execute:

bundle install

or simply install it from the command line:

gem install simple_proxy

Usage

To use Simple Proxy, you can require it in your application:

require 'simple_proxy'

Starting the Server

To start the server:

SimpleProxy.run!

Stopping the Server

To stop the server:

SimpleProxy.quit!

CLI

You can also start or stop the server from the command line:

simple_proxy start
simple_proxy stop

Proxying Requests

To proxy requests, you can use the '/proxy' endpoint:

get '/proxy' do
  SimpleProxy.proxy(params, request)
end

Server Info

  • Server runs on port 4567 by default.
  • Server binds to '0.0.0.0'

Example

  • Run the server:

    simple_proxy start
  • If you want to solve for CORS for an endpoint say, https://example.com/api/v1/users/token

  • You can simply make a request as following:

    curl -X GET http://localhost:4567/proxy?url=https://example.com/api/v1/users/token
  • This will return the response from the target URL with CORS headers set.

Making Proxy Requests

Once the server is running, you can make proxy requests to the following endpoints:

  • GET /proxy?url=target_url
  • POST /proxy?url=target_url
  • PUT /proxy?url=target_url
  • HEAD /proxy?url=target_url
  • DELETE /proxy?url=target_url

Replace target_url with the URL you want to proxy the request to.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

  • Fork it (https://github.com/Hetu-Labs/simple_proxy/fork)
  • Create your feature branch (git checkout -b feature/fooBar)
  • Commit your changes (git commit -am 'Add some fooBar')
  • Push to the branch (git push origin feature/fooBar)
  • Create a new Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project, you agree to abide by its terms.

Changelog

For all notable changes made to this project, see the Changelog.