Azure 中的 Vue CLI - 代理调用和环境

问题描述

我真的是开发新手,没有 DevOps 方面的经验。我有一个 Vue 应用程序,它有一个使用 Sendgrid 的联系表单。为了在本地进行测试,我已将 vue.config.js 设置为具有代理以解决 CORS 问题:

devServer: {
proxy: "https://api.sendgrid.com/")

然后我在我的组件中使用 Axios 进行调用

this.$http.post("http://localhost:8080/v3/mail/send")

我的问题是,一旦我将应用程序部署到 Azure,如果我只是将 Axios 调用更改为 sendgrid API,我的 Sendgrid 调用会起作用吗?

this.$http.post("https://api.sendgrid.com/v3/mail/send")

此外,当我部署到 Azure 时,我如何处理我保存到 .env 文件中的 API 密钥,因为这些没有提交到 Github?

根据 Sendgrid 文档:

You can create a server-based application,which will protect your API keys from being released to the world. Languages like NodeJS,PHP,Ruby,Python,C#,Go,and Java,and others can be implemented to make calls to the API from the security of a locked down server environment.

Vue 显然是在 node 上运行的,所以在部署之前我还需要做进一步的配置吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)