• Resolved daymobrew

    (@daymobrew)


    My dev site is WordPress Multisite.
    register_rest_route() correctly registers example.com/site-name/wp-json/find-my-blocks/blocks but the find-my-blocks.js script looks for /wp-json/find-my-blocks/blocks

    If I access example.com/site-name/wp-json/find-my-blocks/blocks I see the returned JSON.

    Could wp_localize_script be used to pass the site_url to the script?
    I’m happy to help test any changes.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author edeesims

    (@edeesims)

    Hey @daymobrew,

    I have never tested this with multisite. I will be working on a couple of other things this week, but will add this in hopefully in the next couple of weeks

    Plugin Author edeesims

    (@edeesims)

    @daymobrew I know I’m a little late on this, but a version just released that may have fixed this issue.

    Thread Starter daymobrew

    (@daymobrew)

    Thanks.
    I saw the changelog for 3.2.0 mention the site_url. I’ll give it a try and get back to you.

    Thread Starter daymobrew

    (@daymobrew)

    It didn’t work because of too many slashes in the REST url.
    I got a 404 for the query:
    https://www.example.com/block-demos/wp-json///find-my-blocks/blocks

    Note the 3 forward slashes after wp-json.

    The localized settings have site_url:
    “site_url”:”https:\/\/www.example.com\/blocks-demos\/wp-json\/”

    I removed some of the slashes in the js code. Here is the diff of what worked for me:

    --- find-my-blocks.orig.js	2021-03-22 17:34:04.000000000 +0000
    +++ find-my-blocks.js	2021-03-24 10:18:44.000870300 +0000
    @@ -34537,10 +34537,10 @@
           setBlocks = _react_1$useState2[1];
     
       react_1.useLayoutEffect(function () {
    -    var fetchUrl = "/find-my-blocks/blocks";
    +    var fetchUrl = "find-my-blocks/blocks";
     
         if (find_my_blocks_globals.site_url) {
    -      fetchUrl = "".concat(find_my_blocks_globals.site_url, "/").concat(fetchUrl);
    +      fetchUrl = "".concat(find_my_blocks_globals.site_url, fetchUrl);
         }
     
         fetch(fetchUrl).then(function (res) {
    Plugin Author edeesims

    (@edeesims)

    Hey @daymobrew

    I have updated this in 3.3.2. Can you please try again ??

    Thread Starter daymobrew

    (@daymobrew)

    3.3.2 works on my multisite installation. Brilliant. Thanks.

    Plugin Author edeesims

    (@edeesims)

    Great to hear!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Wrong REST API path accessed on Multisite’ is closed to new replies.