首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Zoho满足api集成时,react应用程序中的CORS策略错误

在Zoho满足api集成时,react应用程序中的CORS策略错误
EN

Stack Overflow用户
提问于 2022-10-15 10:31:26
回答 1查看 31关注 0票数 0

我一直在尝试将zoho会议与我的应用程序集成(React是前端,django是后端)。

在获取访问令牌时,我会得到以下错误。

代码语言:javascript
复制
Access to fetch at 'https://accounts.zoho.com/oauth/v2/token?code=1000.53axxxxxxxxxxxxxxxxxxxxxxxxxx2e8e5eb43cfe53005f8d93490&client_id=1000.PGPL8RK7R54UR7JSNKTM2ZRETSF4CI&client_secret=xxxxxxxxxxxxxxxxxxx&redirect_uri=http://localhost:3000/app_store/zoho_meet&grant_type=authorization_code' 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.

这是我的axios代码部分

代码语言:javascript
复制
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded', 
        'Accept': 'application/json',
         "Access-Control-Allow-Origin": "*",
      } 
})

const url = `https://accounts.zoho.com/oauth/v2/token?code=${zcode}&client_id=1000.xxxxxxxxxxxxxxxI&client_secret=92821f12d14cf11162891xxxxxxxxxxxxxxxxxxxx&redirect_uri=http://localhost:3000/app_store/zoho_meet&grant_type=authorization_code`
publicAxios.get(url)
.then((res)=>{
    console.log(res)
})
 .catch((err)=>{
        console.log(err)
})

这里有人能帮我吗?我错过了什么步骤?

EN

回答 1

Stack Overflow用户

发布于 2022-10-17 23:31:31

我用Netlify的无服务器函数(AWS Lambda函数)从我的React应用程序连接到Zoho Api。我通过无服务器函数进行所有Api调用。在浏览器(客户端)中运行时,对Zoho的Api调用失败,出现CORS错误。它必须在服务器上运行。一个人也可以使用谷歌功能,但我还没有尝试过。Netlify文档很棒。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74078647

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档