Lambda Environment - CORS Issue

I am currently working on setting up a remote environment with the server hosted within a Lambda function. The server is up and running and I was able to finish the setup of the environment in Forest, but when I tried to enter in my credentials to log into the environment, I got a CORS issue with the forest/sessions route. I was wondering if this might be something related to the setup of the Lambda server, or something else? Thank you in advance!

Hi @Matt,

Would you mind checking in the network tab of your browser if the /forest/sessions response have the Access-Control-Allow-Origin header. Also, would you mind sharing any error messages from your browser console?

I imagine that you have to configure your Lambda/API gateway to allow this header to be present in the response, like this using API Gateway, or equivalent. That said, I’m no expert of Lambda, so I might be wrong, but a screenshot of the failing call on /forest/sessions & the error message might help :pray:

Hey @jeffladiray! When you said enable cors on the API Gateway I was like oh yeah! But it looks like I still run into the error after enabling CORS. I’ve spent the day trying to make sure there wasn’t anything inside of my api configuration, but I can’t find anything. It’s an exact replica of other api’s that are working.

Here’s a screenshot of the console. Is there anything specific I should change in regards to the errors or something that should be revised in the codebase?

Hi @Matt,

The first error in this screen indicates Access-Control-Allow-Headers is missing forest-environment-id in the preflight response of the gateway.

Maybe you can compare the network calls between your working API and the failing one?
Looking for a difference in these response headers.

Link provided by @jeffladiray seems good to configure your API.

A same kind of issue is here


1 Like