PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Written By
Views

How to fix AWS Lambda & API Gateway cors Error

How to fix AWS Lambda & API Gateway cors Error

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.

Comments (0)

loading comments