liveblog icon indicating copy to clipboard operation
liveblog copied to clipboard

Filtering the rest api endpoint url's seems inconsistant

Open WPprodigy opened this issue 7 years ago • 1 comments

On wpcom, the REST API endpoint url needs to be filtered so the mapped domain is used in the REST API calls rather than the backend site url (for CORS reasons I believe). But as you go down this rabbit hole, you find problems.

Filter: liveblog_endpoint_url

Found here: https://github.com/Automattic/liveblog/blob/1fcc12e4ee9ed51b47873d650431020d9db0956d/liveblog.php#L1147

Despite it's name, this only filters the entries endpoint. Filtering here works correctly though and allows calls like https://example[dot]com/wp-json/liveblog/v1/118535/entries/1533355004/1533356947/ to be filtered. But that doesn't cover all of the needed scenarios.

Suggestion: This should be labeled liveblog_entries_endpoint_url to better explain what it does.

Filter: liveblog_endpoint_base_url

There once lived a filter here (or will?): https://github.com/Automattic/liveblog/blob/0e7e4c641fd80ad8eaace66c6ad8e8cb332f45a9/classes/class-wpcom-liveblog-rest-api.php#L49

This filter seems to be non-existent here in GH, but exists on wpcom right now.

Suggestion: This should be added / sync'd up between wpcom and GH.

Secondly, after much digging, I found this filter needs an earlier priority on preprod sites? So that may be worth exploring.

WPprodigy avatar Aug 04 '18 05:08 WPprodigy

@philipjohn It looks like the liveblog_endpoint_base_url filter was omitted from 1.9:

1.7: https://github.com/svn2github/wordpress-vip-plugins/blob/master/liveblog-1.7/classes/class-wpcom-liveblog-rest-api.php#L54

1.8: https://github.com/svn2github/wordpress-vip-plugins/blob/master/liveblog-1.8/classes/class-wpcom-liveblog-rest-api.php#L49

1.9: https://github.com/svn2github/wordpress-vip-plugins/blob/master/liveblog-1.9/classes/class-wpcom-liveblog-rest-api.php#L49

Was this omitted intentionally? I'm working to resolve an issue similar to the one Caleb describes where I need to filter the author endpoint, not just the posts endpoint.

jeremeylduvall avatar Jan 25 '19 20:01 jeremeylduvall