mw.ForeignApi: don’t set origin for same-origin requests
authorLucas Werkmeister <lucas.werkmeister@wikimedia.de>
Mon, 9 Sep 2019 14:55:35 +0000 (16:55 +0200)
committerLucas Werkmeister <lucas.werkmeister@wikimedia.de>
Wed, 11 Sep 2019 14:02:44 +0000 (16:02 +0200)
commitf07b69cf1379ec48cd338d307a4dbdfd60e20577
tree3540a1db1c4d0bf29eb84cd728f93926b5f72bb8
parent1e2cce13eae6d97b312be2e96a70a443a79c4465
mw.ForeignApi: don’t set origin for same-origin requests

If the foreign API has the same host as the current page (e. g. if it’s
actually the same wiki, or multiple wikis are installed under different
paths on the same host), then the browser will not send an Origin
header, and if we still set an origin parameter, then the API will
complain that the two don’t match. Detect this and unset the origin
parameter in that case.

Bug: T208601
Change-Id: Ia006f3dc3283ce3f81d4d72cbe9676a00797c4d0
resources/Resources.php
resources/src/mediawiki.ForeignApi.core.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.ForeignApi.test.js