Expected behavior
To comply with the User Agent policy, clients that cannot set the User-Agent header are "encouraged" to set the Api-User-Agent header. To support this, I would like to include the Api-User-Agent header in the JavaScript examples in the API Portal. For example:
let response = await fetch( 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth',
{
headers: {
'Api-User-Agent': 'APP_NAME (EMAIL_OR_CONTACT_PAGE)',
'Authorization': 'Bearer ACCESS_TOKEN'
}
}
);
response.json()
.then(console.log).catch(console.error)Observed behavior
The example above gives the error blocked by CORS policy: Request header field api-user-agent is not allowed by Access-Control-Allow-Headers in preflight response. This happens with both the core and feed namespaces.
When I try the example above with the MediaWiki Core REST API, I get the same error. However, when I try with a RESTBase API endpoint (https://en.wikipedia.org/api/rest_v1/page/title/Earth), the Api-User-Agent is allowed and the example works.
Proposal
Allow the Api-User-Agent header in API Gateway requests, similar to T76340: API CORS preflight response should allow Api-User-Agent header