I have enabled CORS for the golang REST app deployed on GAE. I don't use cloud endpoints. Its a simple app that exposes a GET and a POST api and works fine on POSTMAN. However cannot use any js client to POST because of CORS error.
httpServer = &http.Server{
Addr: ":8080",
Handler: handlers.CORS(
handlers.AllowedOrigins([]string{"*"}),
handlers.AllowedHeaders([]string{"Authorization", "Access-Control-Allow-Headers"}),
handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"}))(router),
ReadTimeout: timeout,
WriteTimeout: timeout,
MaxHeaderBytes: 1 << 20,
}
}
Any pointers will help.