中间件“ strapi :: session”:需要应用程序键。请在config/server.js中设置app.keys(ex:键:[' mykeya',' mykeyb'])
试图设置Strapi和Cloudinary 我看了两个视频,他们都可以,但是我有一个错误,告诉我为什么?
中间件“ strapi :: session”:需要应用键。请设置 config/server.js中的app.keys(ex:键:['mykeya','mykeyb'])
https://i.sstatic.net/xopkq.png
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: 'cloudinary',
providerOptions: {
cloud_name: env('CLOUDINARY_NAME'),
api_key: env('CLOUDINARY_KEY'),
api_secret: env('CLOUDINARY_SECRET'),
},
actionOptions: {
upload: {},
delete: {},
},
},
},
// ...
});
” alt =
HOST=0.0.0.0
PORT=1337
CLOUDINARY_NAME="my data"
CLOUDINARY_KEY="my data"
CLOUDINARY_SECRET="my data"
JWT_SECRET=my data
=“ https://i.sstatic.net/xopkq.png” <
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
app: {
keys: env.array('APP_KEYS'),
},
});
img src =
module.exports = [
'strapi::errors',
'strapi::security',
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
'strapi::query',
'strapi::body',
'strapi::session',
'strapi::favicon',
'strapi::public',
];
“
module.exports = ({ env }) => ({
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
apiToken: {
salt: env('API_TOKEN_SALT'),
},
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来您没有
app_keys
在.env
文件中定义(假设您要共享完整文件),以及其他一些ENV变量使用Strapi的内置env实用程序访问。在您的
.env
中,您应该具有以下值的值,该值应遵循此格式:您可以从Strapi的开发文档中阅读有关环境配置的更多信息:
It looks like you don't have
APP_KEYS
defined in your.env
file (assuming you're sharing the full file), as well as some other env variables you're accessing using strapi's built in env utility.In your
.env
you should have a value for the following that should follow this format:You can read more about environment config from Strapi's development docs:
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#strapi-s-environment-variables
我编写了一个快速的Kotlin脚本,以生成Strapi的必要环境变量。 出于安全原因,您应该在本地运行。但是,您当然可以在 .env 文件中。
I wrote a quick kotlin script to generate the necessary environment variables for Strapi. For security reasons, you should run this locally. But you can of course run it on play.kotlin.org. You can put the output of this script in your
.env
file.要解决问题,请创建
.env
文件,该文件应为.env.example
的副本。根据您的Strapi版本,您可能需要添加更多的环境变量。然后在终端中使用节点运行crypto.randombytes(16).toString('Base64')
命令,在运行命令后,您将获得一个生成的键,以在.env <
.env <<<> .env << /code>
以下是工作
.env
文件的示例,只需与加密密钥交换。To resolve the issue create a
.env
file which should be a copy of.env.example
. Depending on your version of Strapi you may need to add more environment variables. Then use Node in the terminal to runcrypto.randomBytes(16).toString('base64')
commands, after running the command you will get a generated key to use in the.env
Here's an example of a working
.env
file, just swapgeneratedKey
with your crypto keys.