Kristo Cule
Kristo Cule

Reputation: 157

Is there a way to invoke API Gateway directly from my React frontend

I created my Lambda Functions and their routes in the API Gateway within the AWS Console. The functions all work within the Testing Tab in Lambda on the console. My React app is very standard and will be pushed to AWS Amplify.

I cannot find any resources on how to correctly invoke the deployed link of my API Gateway from my frontend. Before when working with a local backend, I was able to invoke my backend from my frontend easily with Axios. I tried using axios in my ReactJS frontend with the URL for my API Gateway, but this led to several errors as well such as (No Authentication Token) and (No Access-control-allow-origin header). I've spent hours looking and trying different things to resolve those but every time I always come back to where I started.

Looking for some direction, thank you in advance.

Upvotes: 1

Views: 2549

Answers (1)

nirvana124
nirvana124

Reputation: 1033

No Authentication Token will come if on you are not passing required auth token.

Access-control-allow-origin will be there if you have not enabled CORS on api gateway resource and also you need to pass cors headers in response from your lambda if you are using LAMBDA_PROXY integration. For more details refer this.

Upvotes: 1

Related Questions