Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Discord OAuth2 #25

Merged
merged 8 commits into from
Jul 27, 2024
Prev Previous commit
Next Next commit
chore: Update prodHandler to use clienturl flag for Access-Control-Al…
…low-Origin
f-fsantos committed Jul 10, 2024
commit 214f7e62381de58e741fe5dd32935350e180dc00
6 changes: 3 additions & 3 deletions rogueserver.go
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ func main() {
}

// start web server
handler := prodHandler(mux)
handler := prodHandler(mux, gameurl)
if *debug {
handler = debugHandler(mux)
}
@@ -124,11 +124,11 @@ func createListener(proto, addr string) (net.Listener, error) {
return listener, nil
}

func prodHandler(router *http.ServeMux) http.Handler {
func prodHandler(router *http.ServeMux, clienturl *string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type")
w.Header().Set("Access-Control-Allow-Methods", "OPTIONS, GET, POST")
w.Header().Set("Access-Control-Allow-Origin", "https://pokerogue.net")
w.Header().Set("Access-Control-Allow-Origin", *clienturl)

if r.Method == "OPTIONS" {
w.WriteHeader(http.StatusOK)
Loading