mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-04-02 02:57:15 +08:00
chore: Update prodHandler to use clienturl flag for Access-Control-Allow-Origin
This commit is contained in:
parent
262a04876b
commit
214f7e6238
@ -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…
x
Reference in New Issue
Block a user