create `nonce` only if user is logged in.
This commit is contained in:
parent
31c97a2fe3
commit
8a4beeacb4
|
@ -4,15 +4,17 @@ export const tainacan = axios.create({
|
|||
baseURL: tainacan_plugin.tainacan_api_url
|
||||
});
|
||||
|
||||
if (tainacan_plugin.nonce)
|
||||
if (tainacan_plugin.nonce) {
|
||||
tainacan.defaults.headers.common['X-WP-Nonce'] = tainacan_plugin.nonce;
|
||||
}
|
||||
|
||||
export const wp = axios.create({
|
||||
baseURL: tainacan_plugin.wp_api_url
|
||||
});
|
||||
|
||||
if (tainacan_plugin.nonce)
|
||||
if (tainacan_plugin.nonce) {
|
||||
wp.defaults.headers.common['X-WP-Nonce'] = tainacan_plugin.nonce;
|
||||
}
|
||||
|
||||
export const CancelToken = axios.CancelToken;
|
||||
export const isCancel = axios.isCancel;
|
||||
|
|
|
@ -223,7 +223,7 @@ class Admin {
|
|||
'tainacan_api_url' => esc_url_raw( rest_url() ) . 'tainacan/v2',
|
||||
'wp_api_url' => esc_url_raw( rest_url() ) . 'wp/v2/',
|
||||
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false,
|
||||
'components' => $components,
|
||||
'i18n' => $tainacan_admin_i18n,
|
||||
'user_caps' => $user_caps,
|
||||
|
|
|
@ -326,7 +326,7 @@ function tainacan_blocks_get_plugin_js_settings(){
|
|||
|
||||
$settings = [
|
||||
'root' => esc_url_raw( rest_url() ) . 'tainacan/v2',
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false,
|
||||
'base_url' => $TAINACAN_BASE_URL,
|
||||
'admin_url' => admin_url(),
|
||||
'site_url' => site_url(),
|
||||
|
|
|
@ -4,7 +4,8 @@ const tainacan = axios.create({
|
|||
baseURL: tainacan_blocks.root
|
||||
});
|
||||
|
||||
if (tainacan_blocks.nonce)
|
||||
if (tainacan_blocks.nonce) {
|
||||
tainacan.defaults.headers.common['X-WP-Nonce'] = tainacan_blocks.nonce;
|
||||
}
|
||||
|
||||
export default tainacan;
|
Loading…
Reference in New Issue