Creating nonce does not work in version 5.7
-
Our site is broken since we updated to LS Cache V5.7. Luckily this is only in our Staging environment at the moment.
We use ESI blocks, one of which generates the API request variables for some REST calls. Here is the PHP code:
do_action( 'litespeed_control_set_nocache' );
echo "\n<script id='my-api-request-vars'>";
echo 'var myApiSettings = {"root":"', esc_url_raw( rest_url() ), '","nonce":"', wp_create_nonce('wp_rest'), '"}';
echo "</script>\n";Using V5.6, we get the correct result in the HTML page:
<script id="my_api_request_vars">var myApiSettings = {"root":"https://mysite.com/wp-json/","nonce":"162be98b4d"}</script>
But using V5.7, the nonce generated is just the HTML comment from the plugin, which causes JS errors in the browser:
<script id="my_api_request_vars">var myApiSettings = {"root":"https://mysite.com/wp-json/","nonce":"<!-- Block cached by LiteSpeed Cache 5.7 on 2023-10-24 13:32:15 -->"}</script>
We need help to get this corrected, so that V5.7 behaves correctly, like V5.6 does.
- The topic ‘Creating nonce does not work in version 5.7’ is closed to new replies.