Page MenuHomePhabricator

How to get the location of MWRestAPI from js
Closed, ResolvedPublic

Description

To get the regular API Endpoint we were using

repoApiUrl = serverUrl + scriptPath + '/api.php',

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/527556/20/modules/ext.math.wikibase.js#6

Probably replacing api.php with rest.php should work as well. However, I wonder if there is a more elegant way.

Event Timeline

So the way we do this in other repos is having a configurable API URL.
e.g. https://github.com/wikimedia/Vector/blob/master/skin.json#L257 (see also Popups endpoint )

One of the benefits of this is you can point to a production API from your localhost. Deriving it from wgServer etc means whoever is testing locally must set up a RESTbase instance to test.

@Jdlrobson thank you.
In
https://github.com/wikimedia/Vector/blob/0a47c667d83443e93c1fafcf57b9ba677b520a01/skin.json#L257
I see that you set an empty default. However, I was wondering where do I get the default value for the current rest.php. If I start to construct the path in the math extension any changes to the default path of rest.php will have to be applied in parallel to MW-core and the math extension. Conventions like that caused headaches in the past, thus I would want to avoid that in the future.

Removing inactive assignee (Platform Engineering: Please unassign tasks of previous team members.)

Physikerwelt claimed this task.