Skip to content

Commit aa999a2

Browse files
committed
Pass base URL to use with JS fetch
1 parent 93fb453 commit aa999a2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/admin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ const AdminPage = () => {
2424
const closeChangelogModal = () => setIsChangelogModalOpen( false );
2525

2626
useEffect( () => {
27-
let restUrl = `/wp-json/wp-rollback/v1/fetch-info/?type=${queryArgs.type}&slug=${queryArgs.type === 'theme' ? queryArgs.theme_file : queryArgs.plugin_slug}`;
27+
28+
let restUrl = `${wprData.baseUrl}/wp-json/wp-rollback/v1/fetch-info/?type=${queryArgs.type}&slug=${queryArgs.type === 'theme' ? queryArgs.theme_file : queryArgs.plugin_slug}`;
29+
30+
2831

2932
fetch( restUrl )
3033
.then( ( response ) => response.json() )

wp-rollback.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ public function scripts( $hook ): void {
273273
wp_localize_script( 'wp-rollback-plugin-admin-editor', 'wprData', [
274274
'rollback_nonce' => wp_create_nonce( 'wpr_rollback_nonce' ),
275275
'adminUrl' => admin_url( 'index.php' ),
276+
'baseUrl' => get_site_url(),
276277
'logo' => plugins_url( 'src/assets/logo.svg', __FILE__ ),
277278
'avatarFallback' => plugins_url( 'src/assets/avatar-plugin-fallback.jpg', __FILE__ ),
278279
'referrer' => wp_get_referer(),

0 commit comments

Comments
 (0)