gpt4 book ai didi

vue.js - Nuxt key 和 reCaptcha

转载 作者:行者123 更新时间:2023-12-03 06:47:36 29 4
gpt4 key购买 nike

我正在使用 nuxt.js对预渲染的 html 页面使用通用模式,并从 Google reCaptcha 获得我的 key 。nuxt.js 在哪里应用程序是存储 key 的最佳位置吗?他们在 env 中做吗? nuxt.config.js 中的对象?

export default {
env: {
secret: process.env.SECRET
}
}
还有,当应用程序是用 nuxt generate 生成时,它是如何工作的?应用程序是客户端? env 文件保留在服务器上并且永远不会暴露给客户端,或者是否所有内容都被编译和打包以发送给客户端?

最佳答案

如果你有 Nuxt 2.13+,你可以使用 privateRuntimeConfignuxt.config.js .在那里您可以链接到您的 .env, key 将被注入(inject)服务器,并且在前端不可见。

privateRuntimeConfig should hold all env variables that are privateand that should not be exposed on the frontend. This could include areference to your API secret tokens for example.


More info in the Nuxt Blog

关于vue.js - Nuxt key 和 reCaptcha,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62707691/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com