Request public API from lambda function. Local dev: Success. Published: 403

Does someone have an idea what could be happening?
I have 1 very simple function, that makes a POST request with axios to a public API.
When I run it locally using netlify-lambda serve and I call the function through Postman, the lambda-function makes the request to the public API and it succeeds.
When I deploy the function and call it on the published url (also with Postman) I can’t access the API, it returns forbidden 403.

What can be different in the 2 requests, when the code setting the request is equal?

hi there,

to me that seems like a CORS issue, potentially. Are you receiving any error messages?


Isn’t CORS issue only when you’re making a request from a browser? I thought that by making the request server side from a lambda function, you are bypassing CORS issues.

I notice by logging the succes request locally, in the returned headers is a set-cookie attribute with two items in a array, looks like 2 sessionid’s
Could it be that the Netlify-server doesn’t accept this while my laptop does ?

edit: I notice they block AWS origin. I’m solving it another way

sounds good, @peterDijk. Let me know if you need help with anything else.

1 Like