Commit 8348a61b authored by Rafael's avatar Rafael

added cors package to avoid allow origin *

parent 089b5794
Pipeline #22913870 passed with stage
in 2 minutes and 33 seconds
......@@ -10,6 +10,7 @@ import (
"net/http"
"os"
"github.com/rs/cors"
log "github.com/sirupsen/logrus"
"github.com/go-redis/redis"
......@@ -66,14 +67,20 @@ func main() {
/*
* Handle requests
*/
http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
mux := http.NewServeMux()
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write(page)
}))
http.Handle("/graphql", authenticationMiddleware(&Handler{Schema: schema}))
http.Handle("/metrics", promhttp.Handler())
mux.Handle("/graphql", authenticationMiddleware(&Handler{Schema: schema}))
mux.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(":8080", nil))
handler := cors.New(cors.Options{
AllowedOrigins: []string{"http://localhost:3000", "https://www.shereland.com", "https://graphql.shereland.com"},
AllowCredentials: true,
Debug: false,
}).Handler(mux)
log.Fatal(http.ListenAndServe(":8080", handler))
}
// TODO: Change authentication to JWT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment