Getting CORS error when calling AWS API from Jquery

Sandeep Soni

Getting CORS error when calling AWS API from Jquery.

CORS has enabled in API side and I can call using react > Axios but we have to use Jquery for this application.

using this code:

 $.ajax({
      type: 'POST',
      url: "https://awsapiurlhere",
      crossDomain: true,
      async:true,
      data: {
      aaa: "444",
      bbb: "aaa",
      ccc: "ccc"
      },
      dataType: 'JSON',
      cors: true ,
      contentType:'application/json',
      headers: {
          "Access-Control-Allow-Origin":"*",
      },
      success: function(response, status, xhr) {
        if (response) {
          console.log("The username you typed has been used!", status);
        } else {
           console.log("No responce" , status);
        }
      },
      error: function(xhr, status, error) {
       console.log("Something went wrong!", status );
      }
    });

getting

Access to XMLHttpRequest at 'https://url' from origin 'https://cdpn.io' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.

Steve

You are sending the Access-Control-Allow-Origin as part of the request. As per the error message the request header is not allowed by the CORS policy. You do not need this header in the request as it is a response header. Removing this header from the request will resolve this issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

NodeJS CORS error when calling api from localhost Vue project

Error with CORS when calling local c# api from an Angular project

CORS issues when calling AWS secrets manager from Lambda function

Getting this CORS error on my react app when calling my API - No 'Access-Control-Allow-Origin' header is present on the requested resource

CORS error when jquery ajax request on api

AWS API Gateway endpoint gives CORS error when POST from static site on S3

CORS error when calling Firebase Callable Functions from Angular?

CORS error when calling RESTful services from behind corporate firewall

AWS Lambda calling API gateway getting 500 internal server error

How to avoid the CORS error from an API created in AWS API Gateway?

Getting CORS error in ReactJS app when attempting to execute localhost API

Getting CORS error when using variable in api call

Getting CORS error from appveyor rest api using angular

Error not getting any response from calling an api from javascript

Getting error when calling PayPal API in sandbox mode

Getting Error When Calling Magento SOAP API in Objective-C

Getting KeyError: 'Endpoint' error in Python when calling Custom Vision API

AWS Api Gateway 403 error - CORS enabled from all origins

AWS Amplify, "Error: No credentials" when getting items from AppSync graphql API

Bad Request error when calling from jquery ajax to API contrroller ASP.net Core

getting error when calling a procedure from a trigger in Oracle

Getting "Syntax Error: Unexpected Token" when calling a function from ajax

Chrome is ignoring Access-Control-Allow-Origin header and fails CORS with preflight error when calling AWS Lambda

CORS issue with calling an API using jQuery

CORS policy Error when trying to fetch information from an API

Laravel api CORS error when posting from js

AWS Lambda function sometimes getting error when axios call API

Jquery Ajax throw error when calling web api action

Always getting this CORS error during API fetching