I’m having an issue with the MediaWiki API that I have never encountered before.
I’m trying to make a call to the following URL from an browser application:
it triggers a 301 redirect to:
but the origin=*
seams to have no affect resulting in an CORS error, details below. It seams like that the 301 step does not support CORS.
Is there a known way around this issue?
Client error
Failed to load https://commons.wikimedia.org/w/api.php/?action=query&format=json&origin=*&prop=pageimages&titles=File:Swl-bil-spreadthesign-4014.ogv&converttitles=1&piprop=thumbnail|name|original&pithumbsize=110: Redirect from 'https://commons.wikimedia.org/w/api.php/?action=query&format=json&origin=*&prop=pageimages&titles=File:Swl-bil-spreadthesign-4014.ogv&converttitles=1&piprop=thumbnail|name|original&pithumbsize=110' to 'https://commons.wikimedia.org/w/api.php?action=query&format=json&origin=%2A&prop=pageimages&titles=File%3ASwl-bil-spreadthesign-4014.ogv&converttitles=1&piprop=thumbnail%7Cname%7Coriginal&pithumbsize=110' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
Network request details
GENERAL:
Request URL: https://commons.wikimedia.org/w/api.php/?action=query&format=json&origin=%2A&prop=pageimages&titles=File%3ASwl-bil-spreadthesign-4014.ogv&converttitles=1&piprop=thumbnail%7Cname%7Coriginal&pithumbsize=110
Request Method: GET
Status Code: 301
Remote Address: 91.198.174.192:443
Referrer Policy: no-referrer-when-downgrade
REQUEST HEADERS:
age: 0
backend-timing: D=31460 t=1528561130373024
cache-control: no-cache
content-encoding: gzip
content-length: 116
content-type: text/html
date: Sat, 09 Jun 2018 16:18:50 GMT
location: https://commons.wikimedia.org/w/api.php?action=query&format=json&origin=%2A&prop=pageimages&titles=File%3ASwl-bil-spreadthesign-4014.ogv&converttitles=1&piprop=thumbnail%7Cname%7Coriginal&pithumbsize=110
server: mw1314.eqiad.wmnet
status: 301
strict-transport-security: max-age=106384710; includeSubDomains; preload
vary: Accept-Encoding
via: 1.1 varnish (Varnish/5.1), 1.1 varnish (Varnish/5.1), 1.1 varnish (Varnish/5.1)
x-analytics: WMF-Last-Access=09-Jun-2018;https=1
x-cache: cp1054 pass, cp3041 pass, cp3040 pass
x-cache-status: pass
x-client-ip: 155.4.130.151
x-content-type-options: nosniff
x-powered-by: HHVM/3.18.6-dev
x-varnish: 991855571, 395090200, 350026624
RESPONSE HEADERS:
:authority: commons.wikimedia.org
:method: GET
:path: /w/api.php/?action=query&format=json&origin=%2A&prop=pageimages&titles=File%3ASwl-bil-spreadthesign-4014.ogv&converttitles=1&piprop=thumbnail%7Cname%7Coriginal&pithumbsize=110
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9,no;q=0.8,sv;q=0.7
cookie: commonswikiUserID=3267225; commonswikiUserName=Abbe98; forceHTTPS=true; centralauth_User=Abbe98; centralauth_Token=dbe96916c917c00fb018b409c499ec1f; CP=H2; GeoIP=SE:::59.32:18.06:v4; VEE=wikitext; __mmapiwsid=703a5d52-93bf-11e7-aef4-8136043f0ff6:66b7299b614af3f7398669b70ae1055e82bba00a; WMF-Last-Access-Global=08-Jun-2018; WMF-Last-Access=09-Jun-2018; commonswikiSession=vlviemshvepvuqcdd87knf8s1d0q2sab; centralauth_Session=f3d2dabc2303b50bbe634e9259a9f6d2
dnt: 1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36 OPR/53.0.2907.68
QUERY PARAMETERS:
action: query
format: json
origin: *
prop: pageimages
titles: File:Swl-bil-spreadthesign-4014.ogv
converttitles: 1
piprop: thumbnail|name|original
pithumbsize: 110