运营网站是什么意思住房城乡建设干部学院网站

张小明 2026/1/10 8:23:30
运营网站是什么意思,住房城乡建设干部学院网站,济南网站建设模板,友情链接查询结果Uncaught ReferenceError: SharedArrayBuffer is not defined这个错误通常是因为浏览器的安全策略限制导致的。SharedArrayBuffer 错误原因SharedArrayBuffer 需要特殊的浏览器安全设置才能使用#xff0c;主要是因为安全漏洞#xff08;如 Spectre 攻击#xff09;的原因主要是因为安全漏洞如 Spectre 攻击的原因现代浏览器默认禁用了它。跨源隔离Cross-Origin Isolation要在浏览器中使用SharedArrayBuffer必须启用跨源隔离。这需要在服务器响应头中设置以下两个头部Cross-Origin-Embedder-Policy: require-corpCross-Origin-Opener-Policy: same-origin或更宽松的配置Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: same-origin使用本地服务器而非文件协议不要直接双击 HTML 文件打开file:// 协议而是使用本地服务器。本地开发时的快速解决方案第一步Chrome 浏览器禁用 Web 安全启动 Chrome 时添加以下标志bashchrome --disable-web-security --user-data-dir/tmp/chrome-test在Windows系统上启动 Chrome 并添加标志的方法方法1使用 CMD 命令行最简单按Win R输入cmd回车在 CMD 中输入cmdC:\Program Files\Google\Chrome\Application\chrome.exe --disable-web-security --user-data-dirC:\temp\chrome-test方法2在 PowerShell 中正确的语法powershell C:\Program Files\Google\Chrome\Application\chrome.exe --disable-web-security --user-data-dirC:\temp\chrome-test或者powershellStart-Process C:\Program Files\Google\Chrome\Application\chrome.exe -ArgumentList --disable-web-security, --user-data-dirC:\temp\chrome-test验证是否成功启动后你应该看到 Chrome 顶部的警告横幅text您使用的是不受支持的命令行标记--disable-web-security。稳定性和安全性会有所下降。后续页面打开都在这个新弹出的窗口中进行测试其他方式创建快捷方式右键点击 Chrome 快捷方式选择属性在目标字段的末尾添加text--disable-web-security --user-data-dirC:\temp\chrome-test完整的目标路径应该类似textC:\Program Files\Google\Chrome\Application\chrome.exe --disable-web-security --user-data-dirC:\temp\chrome-test点击应用然后双击此快捷方式启动或者使用 Chrome 扩展程序推荐但可能无法获取安装这些扩展可以绕过 CORS 限制Allow CORS: Access-Control-Allow-OriginChrome Web Store 链接https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf安装后点击图标开启/关闭Moesif CORS功能更强大可以自定义配置链接https://chrome.google.com/webstore/detail/moesif-origin-cors-change/digfbfaphojjndkpccljibejjbppifbcHTTPS要求请注意大多数浏览器要求使用HTTPS才能启用SharedArrayBufferlocalhost除外。即使禁用了 Web 安全SharedArrayBuffer仍然需要特定的 HTTP 头部才能启用。浏览器的警告横幅只是禁用了 CORS但没有设置必要的 COOP/COEP 头部。第二步必须设置正确的响应头使用本地服务器并设置头部1、使用 Node.js Expressjavascript// server.js const express require(express); const app express(); const path require(path); // 设置必需的头部 app.use((req, res, next) { res.setHeader(Cross-Origin-Opener-Policy, same-origin); res.setHeader(Cross-Origin-Embedder-Policy, require-corp); res.setHeader(Access-Control-Allow-Origin, *); next(); }); app.use(express.static(.)); app.listen(8080, () { console.log(Server running at http://localhost:8080/); console.log(Headers set: COOPsame-origin, COEPrequire-corp); });运行bashnode server.js安装 Express# 临时使用淘宝镜像安装npm install -g express --registryhttps://registry.npmmirror.com# 或者设置永久使用淘宝镜像npm config set registry https://registry.npmmirror.com# 验证配置npm config get registry2、使用纯 Node.js无需额外安装 Express创建server.jsjavascriptconst http require(http); const fs require(fs); const path require(path); const server http.createServer((req, res) { console.log(${req.method} ${req.url}); // 设置必需的头部 res.setHeader(Cross-Origin-Opener-Policy, same-origin); res.setHeader(Cross-Origin-Embedder-Policy, require-corp); res.setHeader(Access-Control-Allow-Origin, *); res.setHeader(Access-Control-Allow-Methods, GET, POST, OPTIONS); res.setHeader(Access-Control-Allow-Headers, Content-Type); // 处理 OPTIONS 预检请求 if (req.method OPTIONS) { res.writeHead(200); res.end(); return; } // 确定请求的文件路径 let filePath . req.url; if (filePath ./) { filePath ./worker.html; // 默认加载你的 HTML 文件 } // 获取文件扩展名 const extname path.extname(filePath); let contentType text/html; // 根据扩展名设置 Content-Type switch (extname) { case .js: contentType text/javascript; break; case .css: contentType text/css; break; case .json: contentType application/json; break; case .png: contentType image/png; break; case .jpg: contentType image/jpg; break; case .wasm: contentType application/wasm; break; } // 读取文件 fs.readFile(filePath, (error, content) { if (error) { if (error.code ENOENT) { // 文件不存在 fs.readFile(./404.html, (err, notFoundContent) { if (err) { res.writeHead(404, { Content-Type: text/plain }); res.end(404 Not Found\n); } else { res.writeHead(404, { Content-Type: text/html }); res.end(notFoundContent, utf-8); } }); } else { // 服务器错误 res.writeHead(500); res.end(Server Error: error.code); } } else { // 成功响应 res.writeHead(200, { Content-Type: contentType, Content-Length: content.length }); res.end(content, utf-8); } }); }); const port 8080; server.listen(port, () { console.log(Server running at http://localhost:${port}); console.log(Required headers are set:); console.log( Cross-Origin-Opener-Policy: same-origin); console.log( Cross-Origin-Embedder-Policy: require-corp); console.log( Access-Control-Allow-Origin: *); console.log(\nOpen your browser to: http://localhost:8080/worker.html); });3、使用 Python最简单无需网络如果你安装了 Python3WSL Ubuntu 通常自带bash# 创建 Python 服务器脚本 cat sab_server.py EOF import http.server import socketserver import os PORT 8080 class SharedArrayBufferHandler(http.server.SimpleHTTPRequestHandler): def end_headers(self): # 设置 SharedArrayBuffer 必需的头部 self.send_header(Cross-Origin-Opener-Policy, same-origin) self.send_header(Cross-Origin-Embedder-Policy, require-corp) self.send_header(Access-Control-Allow-Origin, *) super().end_headers() def log_message(self, format, *args): # 简化日志输出 print(f[{self.log_date_time_string()}] {self.address_string()} - {format%args}) # 切换到脚本所在目录 script_dir os.path.dirname(os.path.abspath(__file__)) os.chdir(script_dir) print(\n *50) print( SharedArrayBuffer Development Server) print(*50) print(f URL: http://localhost:{PORT}) print(f Directory: {script_dir}) print(\n Headers configured:) print( • Cross-Origin-Opener-Policy: same-origin) print( • Cross-Origin-Embedder-Policy: require-corp) print( • Access-Control-Allow-Origin: *) print(\n Available HTML files:) for file in os.listdir(.): if file.endswith(.html): print(f → http://localhost:{PORT}/{file}) print(\n *50) print(Press CtrlC to stop the server) print(*50 \n) with socketserver.TCPServer((, PORT), SharedArrayBufferHandler) as httpd: try: httpd.serve_forever() except KeyboardInterrupt: print(\n Server stopped by user) EOF # 运行 Python 服务器 python3 sab_server.py启动步骤# 1. 进入你的项目目录 cd /mnt/d/code/jinqiu/myStudy # 2. 使用 Python 服务器如果已安装 Python3 python3 server.py # 3. 或者使用 Node.js 服务器如果已安装 Node.js node server.js # 4. 打开浏览器访问 # http://localhost:8080/worker.html # 或 # http://localhost:8080/test-sab.html验证是否成功访问http://localhost:8080/worker.html后按 F12 打开开发者工具查看Network 标签→ 点击你的文件 → 查看 Response Headers应该能看到Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corp建议方案使用Python 方案最简单因为WSL Ubuntu 自带 Python3无需安装任何额外包自动设置所需头部直接运行cd /mnt/d/code/jinqiu/myStudy python3 sab_server.py一步到位的解决方案在终端中直接运行这个cd /mnt/d/code/jinqiu/myStudy python3 -c import http.server as hs, socketserver as ss, os, sys p8080 class H(hs.SimpleHTTPRequestHandler): def end_headers(self): self.send_header(Cross-Origin-Opener-Policy,same-origin) self.send_header(Cross-Origin-Embedder-Policy,require-corp) self.send_header(Access-Control-Allow-Origin,*) super().end_headers() try: with ss.TCPServer((,p),H) as s: print(f✅ Server: http://localhost:{p}) print( Headers set for SharedArrayBuffer) [print(f http://localhost:{p}/{f}) for f in os.listdir(.) if f.endswith(.html)] print( CtrlC to stop) s.serve_forever() except: print(f❌ Port {p} busy. Try: http://localhost:{p1}) with ss.TCPServer((,p1),H) as s: print(f✅ Now on: http://localhost:{p1}) s.serve_forever() 检测支持在使用 SharedArrayBuffer 之前最好先检测浏览器是否支持// 检查 SharedArrayBuffer 是否可用 if (typeof SharedArrayBuffer undefined) { // 降级方案使用普通 ArrayBuffer console.warn(SharedArrayBuffer is not available. Using fallback.); // 创建一个简单的模拟功能有限 window.SharedArrayBuffer ArrayBuffer; // 或者根据你的需求调整代码逻辑 // 例如使用 worker.postMessage 替代共享内存 }完整示例下面是一个使用 SharedArrayBuffer 的完整示例需要适当的安全头部// 在代码中检测支持情况 function isSharedArrayBufferSupported() { try { if (typeof SharedArrayBuffer ! function) { return false; } // 测试是否可以实际创建 const sab new SharedArrayBuffer(1); return sab instanceof SharedArrayBuffer; } catch (e) { return false; } } if (!isSharedArrayBufferSupported()) { // 提供降级方案或错误提示 console.error(SharedArrayBuffer is not supported in this environment); // 提示用户更新浏览器或使用支持的浏览器 }
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

抚顺做网站网站开发公司代理

在线教育 目录 基于springboot vue在线教育系统 一、前言 二、系统功能演示 详细视频演示 三、技术选型 四、其他项目参考 五、代码参考 六、测试参考 七、最新计算机毕设选题推荐 八、源码获取: 基于springboot vue在线教育系统 一、前言 博主介绍&am…

张小明 2026/1/5 3:29:15 网站建设

网站的后台建设企业网站制作哪些公司制作

5分钟快速定位:微服务追踪如何解决元数据查询瓶颈 【免费下载链接】pinpoint 项目地址: https://gitcode.com/gh_mirrors/pin/pinpoint 在微服务架构中,元数据查询性能直接影响整个系统的稳定性和响应速度。当服务注册延迟、配置同步超时等问题频…

张小明 2026/1/6 4:09:15 网站建设

阳江市住房和城乡规划建设局网站wordpress无法加载主题

跨平台构建系统终极指南:高效管理复杂开发项目 【免费下载链接】blazor Blazor moved to https://github.com/dotnet/aspnetcore 项目地址: https://gitcode.com/gh_mirrors/bl/blazor 在现代软件开发中,跨平台构建系统已经成为项目成功的关键因素…

张小明 2026/1/5 12:06:38 网站建设

电商网站及企业微信订烟室内装饰设计是干什么的

还在为电商数据分析发愁吗?🤔 今天给大家分享一个超实用的数据仓库实战项目,专门针对电商场景,帮你轻松搞定实时计算和离线分析。无论你是想了解数据仓库的搭建过程,还是需要具体的快速部署方案,这篇文章都…

张小明 2026/1/5 21:40:22 网站建设

飞虹网架建设官方网站求购做网站

在数字化转型的浪潮下,无论是传统的商贸企业还是新兴的电商团队,一套高效的进销存管理系统都是刚需。然而,对于许多处于起步阶段的中小企业和技术团队来说,昂贵的商业软件往往让人望而却步。因此,寻找一款既好用又免费…

张小明 2026/1/6 2:31:49 网站建设