Skip to content

Commit

Permalink
notice for safe use and licensing changes (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam010 authored Jun 23, 2020
1 parent 7310efd commit 219b5f8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
> Note: This repository and project is for educational and testing purposes only, any illegal or bad use of project or its hosted service `https://non-cors.herokuapp.com` is solely the responsibility of the users using it. Me or the contributors has nothing to do with that.
> Also, the hosted service https://non-cors.herokuapp.com has been disabled for now, for safety. Sorry for any inconvenience.
# bypass-cors
>a proxy server to bypass CORS (Cross-Origin Resource Sharing) enabled servers
Expand Down Expand Up @@ -37,4 +41,3 @@ Please make your changes in a specific branch and request to pull into master! I

### License
The application, its design and its code all are licensed under the [MIT license.](https://github.com/Shivam010/bypass-cors/blob/master/LICENSE)

2 changes: 1 addition & 1 deletion helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Valuer interface {
func Return(w http.ResponseWriter, res Valuer) {
fmt.Printf("Served with: %d-%v \n", res.StatusCode(), http.StatusText(res.StatusCode()))

w.Header().Set("Content-Type", "application/json; charset=utf-8")
//w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(res.StatusCode())
_, _ = fmt.Fprintln(w, res.Value())
}
Expand Down
28 changes: 28 additions & 0 deletions license.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"net/http"
"strings"
)

const (
licenseKey = "license"
licenseLen = len(licenseKey)
licenseUrl = "https://github.com/Shivam010/bypass-cors/blob/master/LICENSE"
)

func License(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add(licenseKey, licenseUrl)
r.Header.Add(licenseKey, licenseUrl)
path := strings.ToLower(r.URL.Path)
// redirect to license if URL path is "/license*"
if len(path) > licenseLen && path[1:licenseLen+1] == licenseKey {
http.Redirect(w, r, licenseUrl, http.StatusPermanentRedirect)
return
}
h.ServeHTTP(w, r)
w.Header().Add(licenseKey, licenseUrl)
r.Header.Add(licenseKey, licenseUrl)
})
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func main() {

fmt.Printf("\nStarting Proxy ByPass-Cors Server at port(:%v)...\n\n", PORT)

if err := http.ListenAndServe(":"+PORT, &handler{}); err != nil {
if err := http.ListenAndServe(":"+PORT, License(&handler{})); err != nil {
log.Println("\n\nPanics", err)
}
}

0 comments on commit 219b5f8

Please sign in to comment.