Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter bendyorke

    (@bendyorke)

    After further investigation, it seems that the REST api started returning the same rest_url value for any and all _links values, and subsequently the same root site data for any _embedded data. So making a call to:

    `
    [GET] /wp-json/wp/v2/posts/123?_embed
    `

    Returns a structure like:

    `
    {
    “id”: 123,
    …,
    “_links”: {
    “self”: [{ href: “<rest_url>” }],
    “collection”: [{ href: “<rest_url>” }],
    “about”: [{ href: “<rest_url>” }],
    “author”: [{ href: “<rest_url>”, embeddable: true }],
    “replies”: [{ href: “<rest_url>”, embeddable: true }],
    …,
    ]
    }
    `

    Where <rest_url> is the value returned from the rest_url filter function:

    `
    add_filter(‘rest_url’, function() {
    return <rest_url>;
    });
    `

    I was able to restore functionality by updating the rest_url filter function, however I’m not sure what the root cause is, as this snippet does not cause the same issue locally or on other instances. The temporary solution looks like:

    `
    add_filter(‘rest_url’, function( $path = ”){
    $url = str_replace(“https://example.com//&#8221;, ”, $path);
    return “https://api.example.com/wp-json/{$url}”;
    });
    `

    What would cause the wordpress api to just return the rest_url for all _links values?

Viewing 1 replies (of 1 total)