且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

保护 Google Maps JavaScript API 密钥

更新时间:2022-06-22 00:20:04

Google 地图有多种 API 密钥.

There are numerous sorts of API keys for Google Maps.

浏览器/Javascript 键旨在用于获取 JS/前端库,可以使用.

Browser / Javascript keys are meant to be used for fetching JS / Frontend libraries and are okay to use.

只需确保您使用的是浏览器密钥,可在此处找到:https://developers.google.com/maps/documentation/javascript/get-api-key

Simply ensure you're using a browser key, found here: https://developers.google.com/maps/documentation/javascript/get-api-key

您可以进一步添加安全限制以防止密钥在其他地方使用.您也可以按域、IP 地址、android、ios 应用进行限制.

You can further add security restrictions to prevent the key from being used elsewhere. You can restrict by domain, ip address, android, ios apps as well.

注意,服务器端的密钥应该是私有的.

Note, server-side keys should be private.