在 WordPress 中将 API 密钥等私人信息留在 javascript 中是否安全?

Is it safe to leave private information such as API keys in javascript in WordPress?

我在 WordPress 编辑器中添加了一个媒体按钮,就像代码一样

add_action('media_buttons', 'add_my_media_button');
function add_my_media_button() {
    echo '
            <input id="up_to_chevereto" type="file" accept="image/*" multiple="multiple"/>
            <label for="up_to_chevereto" id="up_img_label"><i class="fa fa-picture-o" aria-hidden="true"></i> upload images to Chevereto</label>
          ';
?>
<style type="text/css">...</style>
<script type="text/javascript">
$('#up_to_chevereto').change(function() {
...
});
</script>
<?php
}

我把我的api钥匙留在了javascript区域,不知这里是否安全。

将 API 密钥留在 javascript 代码中总是不安全的。 如果没有必要,请查看 Chevereto 上的 API 密钥设置以限制每个域的使用。 如果这样的选项不可行,那么你应该避免在 javascript 中呈现你的 API 键。