【发布时间】:2019-09-24 10:13:27
【问题描述】:
我正在尝试为getresponse.com 创建前端应用程序。它有自己的API,位于https://api.getresponse.com。当我尝试使用 Axios 或 Fetch 执行任何 javascript 请求表单浏览器时,出现此错误:
Access to XMLHttpRequest at 'https://api.getresponse.com/v3/accounts' from origin 'http://localhost:8080' 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.
在网络标签中我有:
Request URL: https://api.getresponse.com/v3/accounts
Request Method: OPTIONS
Status Code: 400 Bad Request
因此,据我所知,API 无法正确处理来自网络浏览器的“复杂”请求。
现在我只有一个想法 - 制作一些中间件,它将我的请求代理到 API 端点,而无需任何飞行前请求。
我说的对吗?我找不到这种中间件的任何例子。我在哪里可以找到任何信息?
【问题讨论】:
标签: javascript api axios frontend