简体   繁体   English

Quasar + Vue + SSR - 如何隐藏敏感数据,如 API 密钥

[英]Quasar + Vue + SSR - How to hide sensible data, like API Keys

Been working a week on Quasar Framework and were wondering how to hide sensible data on server side.在 Quasar Framework 上工作了一周,想知道如何在服务器端隐藏合理的数据。

Let's imagine I want to fetch some data from third party site, with the use of my own API Key.假设我想使用我自己的 API 密钥从第三方站点获取一些数据。 How could I keep axios requests and API Keys on server side, and retrieve only the fetched result to user?如何在服务器端保留 axios 请求和 API 密钥,并仅向用户检索获取的结果?

Regards.问候。

I use dotenv in my node projects.我在我的节点项目中使用dotenv The basic workflow is to create a .env file in your project's root directory.基本工作流程是在项目的根目录中创建一个 .env 文件。 This file should hold the sensitive data in per-line key=value pairs.该文件应以每行key=value对的形式保存敏感数据。

Then, add .env to your gitignore so your API keys aren't checked into your source control.然后,将 .env 添加到您的 gitignore 中,这样您的 API 密钥就不会被签入您的源代码管理中。 The .env file will need to be included in your deployment to the server, and the dotenv library should be able to read from it. .env 文件将需要包含在您对服务器的部署中,并且 dotenv 库应该能够从中读取。

Some dev workflows use a .env.development file that holds development api keys.一些开发工作流使用一个 .env.development 文件来保存开发 api 密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM