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 - BUG INTEGRAÇÃO #35

Open
jeffotoni opened this issue Feb 28, 2023 · 0 comments
Open

CORS - BUG INTEGRAÇÃO #35

jeffotoni opened this issue Feb 28, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jeffotoni
Copy link
Owner

Cors -> nativo em nosso ambiente middleware
Cors -> não nativo externo atribuindo a rota ( FOCAR NESTE )

c := cors.New(cors.Options{
AllowedOrigins: []string{"http://foo.com"},
})

mux := http.NewServeMux()

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json")
	w.Write([]byte("{\"hello\": \"world\"}"))
})

n := negroni.Classic()
n.Use(c)
n.UseHandler(mux)
n.Run(":3000")

Example:
https://github.com/rs/cors/blob/master/examples/negroni/server.go

@jeffotoni jeffotoni added the enhancement New feature or request label Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants