You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Flask+Gunicorn环境下用Three.js STLLoader加载STL文件遇混合内容错误

STLLoader加载STL文件出现混合内容错误排查

问题现象

在Render.com上部署的Flask+Gunicorn应用中,使用Three.js的STLLoader加载服务器端STL文件时,部分设备浏览器会触发混合内容错误:

Mixed Content: The page at 'https://www.vasedjinn.com/' was loaded over HTTPS, but requested an insecure resource 'http://www.vasedjinn.com/static/stl/surf.stl'. This request has been blocked; the content must be served over HTTPS.

相关代码片段

STLLoader加载逻辑

const loader = new STLLoader();
console.log(stl_path);
loader.load( stl_path, function ( geometry ) {

    const material = new THREE.MeshPhongMaterial( { color: vaseColor, specular: 0x494949, shininess: 100 } );
    vaseMesh = new THREE.Mesh( geometry, material );

    vaseMesh.position.set( 0, 0, 0 );
    vaseMesh.rotation.set(0,0,0);
    vaseMesh.scale.set( 0.02, 0.02, 0.02 );
    vaseMesh.rotation.x = -Math.PI / 2;

    vaseMesh.castShadow = true;
    vaseMesh.receiveShadow = true;

    scene.add( vaseMesh );

} );

STL文件路径构造

var stl_path = {{ url_for("static",filename= '/stl/surf.stl')|tojson }};
stl_path = window.location.href + stl_path;

已尝试的解决步骤

  • 最初使用相对路径//static/stl/surf.stl传入,无效;
  • 改为拼接完整HTTPS路径(日志显示最终路径为https://www.vasedjinn.com//static//stl/surf.stl),但请求仍被自动转为HTTP,报错未解决;
  • 检查STLLoader源码,未找到路径被修改的相关逻辑。

求助方向

  1. 定位并修复STLLoader将HTTPS请求转为HTTP的问题;
  2. 如果上述问题无法解决,希望了解其他从服务器加载STL文件并转换为Three.js对象的可行方案。

内容的提问来源于stack exchange,提问作者Jules Gabriel Pare

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 00:22:49