创建uniCloud新项目并且是新服务空间,运行会报Error: Invalid uni-id config file错误
问题说明
新创建的服务空间,新起的项目,运行查询数据库就会报错,Uncaught (in promise) Error: Invalid uni-id config file,我记得在原来创建项目的时候,是不需要进行配置的,最近创建新项目出现了这个错误。
解决办法
1.找到目录uniCloud -> cloudfunctions -> common -> uni-config-center 下,创建uni-id目录,并创建config.json文件,如下结果所示:
2.在config.json中拷贝如下代码,不用做任何修改
{"passwordSecret": [{"type": "hmac-sha256","version": 1}], "passwordStrength": "medium", "tokenSecret": "0123456789", "requestAuthSecret": "9876543210", "tokenExpiresIn": 7200, "tokenExpiresThreshold": 3600, "maxTokenLength": 10, "passwordErrorLimit": 6, "passwordErrorRetryTime": 3600, "autoSetInviteCode": false, "forceInviteCode": false, "idCardCertifyLimit": 1, "realNameCertifyLimit": 5, "sensitiveInfoEncryptSecret": "", "frvNeedAlivePhoto": false, "userRegisterDefaultRole": [], "app": { "tokenExpiresIn": 2592000,"tokenExpiresThreshold": 864000,"oauth": {"weixin": {"appid": "","appsecret": ""},"qq": {"appid": "","appsecret": ""},"apple": { "bundleId": ""}}},"web": { "tokenExpiresIn": 7200,"tokenExpiresThreshold": 3600,"oauth": {"weixin-h5": { "appid": "","appsecret": ""},"weixin-web": { "appid": "","appsecret": ""}}},"mp-weixin": {"tokenExpiresIn": 259200,"tokenExpiresThreshold": 86400,"oauth": {"weixin": {"appid": "","appsecret": ""}}},"mp-qq": {"tokenExpiresIn": 259200,"tokenExpiresThreshold": 86400,"oauth": {"qq": {"appid": "","appsecret": ""}}},"mp-alipay": {"tokenExpiresIn": 259200,"tokenExpiresThreshold": 86400,"oauth": {"alipay": {"appid": "","privateKey": "", "keyType": "PKCS8" }}},"service": {"sms": {"name": "", "codeExpiresIn": 180, "scene": {"bind-mobile-by-sms": { "templateId": "", "codeExpiresIn": 240 }}},"univerify": {"appid": "" }}
}
上面这段config.json代码来自于uni-id的配置项,如果你懂得如何配置,自己根据下面提供的链接去拷贝即可,如果不懂uni-id,直接按照我的上面两个步骤就可以了。
uni-id的配置项:https://doc.dcloud.net.cn/uniCloud/uni-id/summary.html#config