It is time.
Our serverless backend and infrastructure (that we both created and deployed ourselves with CDK!) is ready so we can connect it to our React app.
In this quick lesson we're going to learn how to connect the React app from the source code of this course to our API as well as how to add appropriate CORS headers to our API response.
After I added the the access-control-allow-origins and method headers, when I saved the file and and ran cdk deploy, I was still getting CORS error when trying to access the app on localhost. I checked lambda in the console and saw that the code was not updated. I also sent a get request in insomnia to check the headers, and the headers were not there. I destroyed the stack and created a new one, hoping it would deploy with my newly added headers - it did not. same issue. I ended up needing to run "npm run build" and then "cdk deploy" again and it worked. headers are showing in insomnia and no CORS errors in the browser on localhost.
The course assumes that you're constantly running "npm run watch" in the background, to avoid building each change