【明道云】如何解决webhook的跨域问题

【背景】

公司引入了明道云,原本是打算利用明道云的整合能力,把明道云平台作为后端,原有的系统保留前端,通过Webhook来实现通信,最终实现系统的整合。

【问题】

直接从外部前端利用webhook向明道云通信时(jquery直接post),发生跨域问题,虽然可以触发后端动作,但是无法正常返回success,导致post后的jquery内容全部无法执行。

例子:

$.post("http://184.41.3.96/api/workflow/hooks/NjQ0N2NmZTczMjYxYjEyMTU5NzA4NDcz",{
    
    "fName":input,"fContent":'{"root":{"data":{"id":"cq6u78fdiqw0","created":1675215125479,"text":"中心主题"},"children":[]},"template":"default","theme":"fresh-blue","version":"1.4.33"}',"fUserName":"{
    
    {user}}"},function(){
    
    
                    						alert("success");
                    					  }
                    			  );

前端返回如下跨域警告:
CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

【方案】

还是不能把自己的后端架空,需要把自己的后端当一个二传手。

  1. 从外部前端Post外部后端;
  2. 从外部后端Post明道云;
  3. 从明道云反馈外部后端;
  4. 从外部后端反馈外部前端;

猜你喜欢

转载自blog.csdn.net/weixin_41697242/article/details/130391752
今日推荐