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

CORS Problem #54

Open
iesreza opened this issue Mar 19, 2020 · 1 comment
Open

CORS Problem #54

iesreza opened this issue Mar 19, 2020 · 1 comment

Comments

@iesreza
Copy link

iesreza commented Mar 19, 2020

Cant connect over different domain because of cors.

@rof20004
Copy link

import (
  "github.com/rs/cors"
  // other imports
)

func main() {
        //setup http server
	serveMux := http.NewServeMux()
	serveMux.Handle("/socket.io/", server)

	// CORS handler
	c := cors.New(cors.Options{
		AllowedOrigins: []string{"*"},
		AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
		AllowedHeaders: []string{"Authorization", "Content-Type", "Accept", "User-Agent", "Referer"},
	})

	handler := c.Handler(serveMux)

	log.Println("Server started")
	log.Panic(http.ListenAndServe(":3000", handler))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants