lmdrouter
lmdrouter copied to clipboard
Issue: CORS Errors on Local Development
I've put lmdrouter
to huge success on live staging and production environments for lambda functions but I'm struggling to use it for debugging on local. Here's my main.go
code:
func main() {
environment := os.Getenv("STAGE")
if environment == "staging" || environment == "production" {
lambda.Start(router.Handler)
} else {
fmt.Println("Ready to listen and serve")
err := http.ListenAndServe(":8080", http.HandlerFunc(router.ServeHTTP))
if err != nil {
log.Fatalf("%+v", err)
}
}
}
Assuming I'm using the library correctly - every request a browser makes via HTTPS results in a CORS error. Funny enough postman had no problem with using the endpoints locally over HTTPS so it's something to do with CORS and OPTIONS
which I'm not an expert on by any means. Any ideas?
I have a local workaround working. I'll try to push a pull request up here in a little bit.