本文介绍ThingWorx Platform平台接口如何访问,出现跨域问题如何解决。参考官方文章CS229450 - How to Enable Cross-Origin Resource Sharing (CORS) in Apache Tomcat for ThingWorx Platform/ThingWorx Navigate
背景
公司服务器部署了一台 ThingWorx Platform,现在另一个系统要调用thingworx中开放的api接口(thingworx如何写api接口可参考官网),访问时浏览器提示错误:

很明显是跨域问题 ,解决方案见下面步骤:
解决方案
1、找到thingworx安装目录下的tomcat下web.xml文件:<Apache Tomcat Install>\webapps\Thingworx\WEB-INF\ ,在 </session-config> 行后面新增
<filter>
<filter-name>CorsFilter</filter-name>

本文介绍了如何解决在访问部署在公司服务器上的ThingWorxPlatform时遇到的跨域问题。通过编辑thingworx安装目录下的Apache Tomcat的web.xml文件,添加CORS过滤器并配置相关参数,以及对OPTIONS请求的处理,可以实现跨域访问。最后提供了一个简单的测试HTML页面来验证接口调用是否成功。
最低0.47元/天 解锁文章
2268

被折叠的 条评论
为什么被折叠?



