小编Pat*_*man的帖子

Vue & Axios + AWS API Gateway & Lambda - CORS + POST 不起作用

我正在尝试通过 AWS API Gateway 创建一个 API 测试函数,以及一个通过 Axios 的 Vue 应用程序调用的 Lambda 函数。它应该从输入元素发送姓名和电子邮件。每次我收到此错误时:

Access to XMLHttpRequest at '[API Gateway URL]' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Run Code Online (Sandbox Code Playgroud)

我已在 API 网关设置中的每个步骤/资源上启用了 CORS(根据本文)。下面是 Vue 组件的代码:

<template>
<div data-app>
        <div class="cell" id="testForm">
    {{responseMsg}}

       <label>Name</label>
       <input v-model="name" type="text" placeholder="Name">
       <label>Email Address</label>
       <input v-model="email" type="email" placeholder="Email Address">
       <button v-on:click="formFunction">Submit</button>
   
   </div>
</div>
</template>

<script>
import axios …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services vue.js aws-lambda aws-api-gateway axios

1
推荐指数
1
解决办法
3091
查看次数