如何将安全的Env变量添加到Remix.run项目?

发布于 2025-02-01 03:58:05 字数 196 浏览 2 评论 0原文

遵循文档添加ENV变量的最佳方法是在您的服务器上添加它们,但是如何处理 Secret url应该在根组件中(例如Google API)?

通过加载程序将它们通过安全性无法解决此问题。任何用户都可以在网络选项卡中看到变量 [网络选项卡中的ENV变量] [1] [1]:https://i.sstatic.net/vizit.png

Following the documentation the best way to add env variables is to add them on your server but how to processed secret url that should be in root component (e.g. Google Api )?

Pass them through loader don't resolve this problem because of security. Any user will be able to see variables in network tab
[Env variable in network tab][1]
[1]: https://i.sstatic.net/VizIt.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如若梦似彩虹 2025-02-08 03:58:05

任何需要保持秘密的API密钥都需要在服务器 上使用,并且在加载程序响应中又不返回。

话虽如此,对于Google地图客户端功能,您别无选择,只能将API密钥曝光。您应该使用Google推荐的限制您的API键到特定的域和API。

Any API key that needs to stay secret needs to be used on the server only and not returned in a loader response.

That being said, for Google Maps client-side functionality, you have no choice but to expose your API key to the client. You should instead secure it using Google's recommended practice of Restricting your API Key to specific domains and APIs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文