lmdrouter icon indicating copy to clipboard operation
lmdrouter copied to clipboard

Issue: CORS Errors on Local Development

Open seantcanavan opened this issue 2 years ago • 1 comments

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?

seantcanavan avatar Apr 22 '22 21:04 seantcanavan

I have a local workaround working. I'll try to push a pull request up here in a little bit.

seantcanavan avatar Apr 25 '22 16:04 seantcanavan