Skip to content

Commit 219b5f8

Browse files
authored
notice for safe use and licensing changes (#16)
1 parent 7310efd commit 219b5f8

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
> 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.
2+
3+
> Also, the hosted service https://non-cors.herokuapp.com has been disabled for now, for safety. Sorry for any inconvenience.
4+
15
# bypass-cors
26
>a proxy server to bypass CORS (Cross-Origin Resource Sharing) enabled servers
37
@@ -37,4 +41,3 @@ Please make your changes in a specific branch and request to pull into master! I
3741

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

helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Valuer interface {
2020
func Return(w http.ResponseWriter, res Valuer) {
2121
fmt.Printf("Served with: %d-%v \n", res.StatusCode(), http.StatusText(res.StatusCode()))
2222

23-
w.Header().Set("Content-Type", "application/json; charset=utf-8")
23+
//w.Header().Set("Content-Type", "application/json; charset=utf-8")
2424
w.WriteHeader(res.StatusCode())
2525
_, _ = fmt.Fprintln(w, res.Value())
2626
}

license.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
"strings"
6+
)
7+
8+
const (
9+
licenseKey = "license"
10+
licenseLen = len(licenseKey)
11+
licenseUrl = "https://github.com/Shivam010/bypass-cors/blob/master/LICENSE"
12+
)
13+
14+
func License(h http.Handler) http.Handler {
15+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
16+
w.Header().Add(licenseKey, licenseUrl)
17+
r.Header.Add(licenseKey, licenseUrl)
18+
path := strings.ToLower(r.URL.Path)
19+
// redirect to license if URL path is "/license*"
20+
if len(path) > licenseLen && path[1:licenseLen+1] == licenseKey {
21+
http.Redirect(w, r, licenseUrl, http.StatusPermanentRedirect)
22+
return
23+
}
24+
h.ServeHTTP(w, r)
25+
w.Header().Add(licenseKey, licenseUrl)
26+
r.Header.Add(licenseKey, licenseUrl)
27+
})
28+
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func main() {
107107

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

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

0 commit comments

Comments
 (0)