Safari Webkit, NotAllowedError: The request is not allowed
使用tauri v2,跑前后端项目学习时,遇到这条报错:
Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
测试代码
console.log(navigator.userAgent); navigator.permissions.query({name:'camera'}).then(per=>console.log(per.state)); navigator.mediaDevices.getUserMedia({audio: true}).then(stream => console.log(stream)).catch(err => console.error(err)); navigator.mediaDevices.getUserMedia({video: true}).then(stream => console.log(stream)).catch(err => console.error(err));
结果
[Log] Mozilla/5.0 (X11; Ubuntu; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15 [Log] prompt [Error] NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. Console Evaluation (Console Evaluation 26:5:115) [Error] OverconstrainedError {message: "Invalid constraint", constraint: "", name: "OverconstrainedError"} Console Evaluation (Console Evaluation 37:3:115)
虽然是prompt
,但没有弹窗申请权限,所以导致NotAllowedError
解决
tauri还不成熟,换用electron吧
https://github.com/tauri-apps/wry/issues/85
分类:
开发
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2022-10-13 码农也要注意身体健康 q(≧▽≦q)