使用Qontak API上传文件时POST请求被Incapsula(Imperva)拦截的解决方法咨询
Qontak API上传文件时POST请求被Incapsula(Imperva)拦截的解决方法咨询
我最近尝试基于Qontak的JS API实现文件上传功能,参考了官方SDK里的file_uploader模块逻辑,但每次发送POST请求到/qontak/chat/v1/file_uploader都被拦截了,返回的是Incapsula(Imperva)的错误页面,完全搞不懂为啥会触发这个拦截,想请教大家怎么解决这个问题!
具体的错误返回内容如下:
request line POST /qontak/chat/v1/file_uploader HTTP/1.1 Error: <html style="height:100%"><head><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><meta name="format-detection" content="telephone=no"><meta name="viewport" content="initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></head><body style="margin:0px;height:100%"><iframe id="main-iframe" src="/_Incapsula_Resource?CWUDNSAI=23&xinfo=14-18748584-0%20NNNY%20RT%281743153273568%20373%29%20q%280%200%200%20-1%29%20r%281%20-1%29%20B15%281%2c501%2c51%29%20U24&incident_id=1767000280150547423-101893486418528014&edet=15&cinfo=01000000ee8e&rpinfo=0&mth=POST" frameborder=0 width="100%" height="100%" marginheight="0px" marginwidth="0px">Request unsuccessful. Incapsula incident ID: 1767000280150547423-101893486418528014</iframe></body></html>
我自己编写的上传代码如下:
const fs = require('fs'); async function uploadMedia() { try { const filePath = './cta-url.png'; if (!fs.existsSync(filePath)) { throw new Error(`File not found at path: ${filePath}`); } const fileBuffer = fs.readFileSync(filePath); const response = await api.file_uploader.uploadFile({file: fileBuffer}); console.log("Upload Response:", response); } catch (error) { console.error("Error:", error.response?.data || error.message); } } uploadMedia();
我实在搞不懂为啥这个请求会被Incapsula拦截,明明是照着SDK的逻辑来写的。有没有朋友遇到过类似的问题?或者知道怎么绕过这个拦截,成功把文件上传到Qontak API?
非常感谢大家的帮助!
备注:内容来源于stack exchange,提问作者Agus Suparman
相关产品推荐
相关产品推荐

