How to fix AWS Lambda & API Gateway cors Error

Jackson Kasi - Oct 13 '22 - - Dev Community

I have been working, with my client( developer ), in AWS Lambda & API-Gateway.

Now we face a cors error while calling API-endpoint in React-JS ( post method ), we tried lots of ways to fix the cors but doesn't work.

NOTE: This API endpoint works fine in postman. but throw cors only in React-JS applications.

Please Help me, anyone.

Thanks

In my code:

Image description

NOT WORK API - CORS ERROR: ( in react js )

Image description


Error:

Access to fetch at 'https://xxx_id_xxx.execute-api.us-east-1.amazonaws.com/xxxx/post/target/page' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player