corsproxy

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 7 Imported by: 1

README

corsproxy

corsproxy is yet another CORS proxy written in Go, designed to bypass CORS restrictions when making requests from web applications.

Features

  • Private Network Targets Disallowed: By default, corsproxy disallows private network targets to enhance security.
  • Configurable Allowed Targets: You can configure the allowed targets to specify which domains are allowed to be accessed through the proxy.

Installation

docker pull ghcr.io/zachcheung/corsproxy
  • go install
go install github.com/zachcheung/corsproxy/cmd/corsproxy@latest

Usage

corsproxy -allowedTargets "https://*.example.com,http://ip.me"

Please refer to rs/cors for detailed information on CORS-related options.

Request examples:

  • http://localhost:8000/http://ip.me

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeParseURL added in v1.1.0

func NormalizeParseURL(rawURL string) (*url.URL, error)

NormalizeParseURL takes a raw URL string, parses it into a *url.URL, and normalizes it by converting the host to lowercase.

func NormalizeURL added in v1.1.0

func NormalizeURL(rawURL string) (string, error)

NormalizeURL takes a raw URL string and normalizes it by converting the host to lowercase.

func StripURLQuery added in v1.1.0

func StripURLQuery(rawURL string) (string, error)

StripURLQuery takes a raw URL string, normalizes it, and returns the URL without the query string.

Types

type CorsProxy

type CorsProxy struct {
	// contains filtered or unexported fields
}

CorsProxy holds the configuration and state for the CORS proxy.

func New

func New(options Options) *CorsProxy

New creates a new CorsProxy instance with the provided options.

func (*CorsProxy) Handler

func (cp *CorsProxy) Handler() http.Handler

Handler returns an HTTP handler that proxies requests with CORS support.

type Options

type Options struct {
	cors.Options
	// AllowedTargets is a list of targets a cross-domain request can reach.
	// If the special "*" value is present in the list, all targets will be allowed except private network targets if `AllowPrivateNetworkTarget` is false.
	// A target may contain a wildcard (*) to replace 0 or more characters (i.e.: `http://*.domain.com`).
	// Only one wildcard can be used per target.
	// Default value is ["*"]
	AllowedTargets []string
	// AllowPrivateNetworkTarget indicates whether to accept private network targets.
	// If a private network target has been added to `AllowedTargets`, there is no need to set `AllowPrivateNetworkTarget` explicitly.
	AllowPrivateNetworkTarget bool
}

Options defines the configuration for the CORS proxy.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL