I have fairly simple setup here as described in the code below. But I am not able to get the CORS
to work. I keep getting this error:
XML
I realize this is an old issue but nonetheless it took me 30min to get this right.
handler = handlers.CORS(
// handlers.AllowedMethods([]string{"GET", "POST", "PUT"}),
handlers.AllowedHeaders([]string{"Accept", "Accept-Language", "Content-Type", "Content-Language", "Origin"}),
// handlers.AllowedOrigins([]string{"*"}),
)(handler)
Things to note:
OPTIONS
, this is part of the CORS handler*
is not a valid wildcard. Typical ajax libraries will send Content-Type
when requesting something like application/json
, so add that as well.*
is the default for AllowedOrigin