Thank you for your answer, you are absolutely right.
I also corrected my mistake. I’ll post the code if it helps.
Code for Cloudflare Workers: https://gist.github.com/richie5um/b2999177b27095af13ec619e44742116
Code for WordPress :
add_filter( 'script_loader_tag', 'add_nonce_to_script', 10, 3 );
function add_nonce_to_script( $tag, $handle, $source ) {
$search = "type="text/javascript"";
$replace = "type="text/javascript" nonce=""";
$subject = $tag;
$output = str_replace($search, $replace, $subject);
return $output;
}
Related Posts:
- How does nonce verification work?
- How to expire a nonce?
- Fatal error: Call to undefined function wp_create_nonce()
- How to add/retrieve the post trash link?
- Using nonce external of WP Admin
- Nonce best practices: hidden input vs. wp_localize_script?
- “The link you followed has expired” when previewing a post
- wp_verify_nonce keeps failing
- Handling nonce generation in AJAX registration process
- increase nonce lifespan
- wp_verify_nonce() via REST always returns false
- Nonce failing in IE
- my theme breaks WP export
- Why am I getting a 403 from check_admin_referer()?
- x-wp-nonce across domains
- wp_create_nonce doesn’t verify when using WP_List_Table
- Handling expired nonces
- What is really “wp_nonce_field” and how does it work? [duplicate]
- Cannot verify nonce
- wp_verify_nonce return false despite correct parameter passed
- WordPress JSON API nonces and Vue development server
- Verify a nonce in Form submission
- phpcs error in WordPress
- Stop WordPress nonces expiring
- Several nonces?
- Nonce for Trashing Item
- Nonce keeps failing
- Public posts – preventing duplicate form submissions
- How to obtain “wp_rest” nonce for WP Statistics plugin manually?
- WordPress “nonce” message
- Why are nonces working in Firefox but not in Chrome?
- wp_verfy_nonce keeps giving false
- Nonce – reissue with ajax poll
- wp_nonce_url generating invalid links
- How to insert wp_nonce field within echoed string
- Nonce check causing issues when creating new post
- Weird nonce validation problem
- Logout button in menu without “wp” in links
- What is a Ray ID (Cloudflare)?
- wp_verify_nonce vs check_admin_referer
- How do I create a user using the new JSON api in 4.7?
- Is wp_nonce_field vulnerable if you know the action name?
- Is it safe to assume that a nonce may be validated more than once?
- Should nonce be sanitized?
- Using Nonces for AJAX that only retrieves data
- WordPress “Link has expired” error on updating posts
- How to verify nonce from Bulk/Quick Edit in save_post?
- WordPress failure when logging out
- Reduce nonce lifespan
- Ajax function returns -1
- Security around save_post hook
- wp_verify_nonce always returns false when logged in as admin
- how to get nonce using json api
- ajax and nonce when JavaScript is in a seperate file
- Confusion on WP Nonce usage in my Plugin
- Can I check for maintenance mode before redirecting to subdomain?
- AJAX requests broken due to HTTPS for wp-admin
- wp_nonce_url to users.php for deleting user not working
- How can I create a plugin installation link?
- Security checking in meta_box save is reluctant?
- How to check an ajax nonce in PHP
- wp_verify_nonce not working
- how to send Ajax request in wordpress backend
- WP Admin AJAX Security – using POST to include a relative URL
- wp_create_nonce() in REST API makes user->ID zero
- ajax nonce verification failing
- wp_create_nonce function doesn’t work inside a plugin?
- Nonce failing on form submission
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Why ajax doesn’t work on certain wordpress hooks?
- Custom login doesn’t work properly
- Woocommerce – Want to block a user agent from accessing specific product pages
- Is there value in using a wp_nonce for POST requests?
- Form Security: nonce vs. jQuery
- Nonce doesn’t validate in nopriv call
- Should I use wp_nonce_field on my contact form?
- Forms and WordPress Nonce
- Why does check_ajax_referer give a 403 error on https websites?
- WordPress is creating nonce as a logged in user but verifying it incorrectly
- How to use nonce
- Where to use nonce
- How to use the wpsnonce clone post link?
- Re-use Nonce in Repeating Event Signup Buttons
- How to add a WordPress Nonce for this form to avoid CSRF
- Reliable way to add nonce to HTTP Header in WordPress?
- On a multisite environment, get the subdomain value as variable
- wp_nonce vs jwt
- Using a nonce Content Security Policy header for style-src for inline style elements returns errors
- How to add a prefix to a WordPress post preview url?
- Time out opening second page in same browser with long running page load
- Fully caching WordPress site by CDN (eg. Cloudflare)
- wp-admin and wp-login.php not Accessible after Cloudflare
- Override plugin function to show invoices even if not logged in
- No Query String vs Ignore Query String in WordPress
- 403 Forbidden on site logo image upload
- Nonce and widget
- Is it necessary to use a WordPress nonce when allowing users to download public data?
- Can not login after moving to cloudflare and adding rules
- Wp doesn’t save meta box data
- Cron job for wp_cron.php running but not publishing scheduled posts