微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。