diff --git a/README.md b/README.md index 1b0f2de..49cfc20 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ Certain sites may display missing images or encounter formatting issues. This ca ### Features - [x] Bypass Paywalls -- [x] Remove CORS headers from responses, Assets, and images ... +- [x] Remove CORS headers from responses, assets, and images ... - [x] Keep site browsable -- [x] Add a debug path +- [x] Add a raw path - [x] Add a API - [x] Docker container - [x] Linux binary - [x] Mac OS binary -- [x] Windows binary (Untested) +- [x] Windows binary (untested) - [x] Remove most of the ads (unexpected side effect) - [x] Basic Auth @@ -53,15 +53,13 @@ docker-compose up -d Or direct by appending the URL to the end of the proxy URL: http://localhost:8080/https://www.google.com - - ### API ```bash curl -X GET "http://localhost:8080/api/https://www.google.com" ``` -### Debug -http://localhost:8080/debug/https://www.google.com +### RAW +http://localhost:8080/raw/https://www.google.com ## Configuration diff --git a/handlers/api.go b/handlers/api.go index dad40b5..28e0346 100644 --- a/handlers/api.go +++ b/handlers/api.go @@ -15,7 +15,8 @@ func Api(c *fiber.Ctx) error { // Get the url from the URL urlQuery := c.Params("*") - body, req, resp, err := fetchSite(urlQuery) + queries := c.Queries() + body, req, resp, err := fetchSite(urlQuery, queries) if err != nil { log.Println("ERROR:", err) c.SendStatus(500) diff --git a/handlers/proxy.go b/handlers/proxy.go index 07d1dc7..d6559b9 100644 --- a/handlers/proxy.go +++ b/handlers/proxy.go @@ -18,9 +18,10 @@ var ForwardedFor = getenv("X_FORWARDED_FOR", "66.249.66.1") func ProxySite(c *fiber.Ctx) error { // Get the url from the URL - urlQuery := c.Params("*") + url := c.Params("*") - body, _, resp, err := fetchSite(urlQuery) + queries := c.Queries() + body, _, resp, err := fetchSite(url, queries) if err != nil { log.Println("ERROR:", err) c.SendStatus(500) @@ -31,17 +32,26 @@ func ProxySite(c *fiber.Ctx) error { return c.SendString(body) } -func fetchSite(urlQuery string) (string, *http.Request, *http.Response, error) { - u, err := url.Parse(urlQuery) +func fetchSite(urlpath string, queries map[string]string) (string, *http.Request, *http.Response, error) { + + urlQuery := "?" + if len(queries) > 0 { + for k, v := range queries { + urlQuery += k + "=" + v + "&" + } + } + urlQuery = strings.TrimSuffix(urlQuery, "&") + + u, err := url.Parse(urlpath) if err != nil { return "", nil, nil, err } - log.Println(u.String()) + log.Println(u.String() + urlQuery) // Fetch the site client := &http.Client{} - req, _ := http.NewRequest("GET", u.String(), nil) + req, _ := http.NewRequest("GET", u.String()+urlQuery, nil) req.Header.Set("User-Agent", UserAgent) req.Header.Set("X-Forwarded-For", ForwardedFor) req.Header.Set("Referer", u.String()) diff --git a/handlers/raw.go b/handlers/raw.go index 29a4aa9..7baa0e5 100644 --- a/handlers/raw.go +++ b/handlers/raw.go @@ -10,7 +10,8 @@ func Raw(c *fiber.Ctx) error { // Get the url from the URL urlQuery := c.Params("*") - body, _, _, err := fetchSite(urlQuery) + queries := c.Queries() + body, _, _, err := fetchSite(urlQuery, queries) if err != nil { log.Println("ERROR:", err) c.SendStatus(500)