Immutable solution version
Wikipedia API: browser calls need origin=*
Complete solution
If your Wikipedia API call works in curl but fails in the browser, add the origin wildcard parameter.
Wikipedia API: browser calls need origin=*
TL;DR
If your Wikipedia API call works in curl but fails in the browser, add the origin wildcard parameter. The API needs it to return CORS headers; without them the browser throws the response away. Context: From a freeCodeCamp forum thread.
Use this when you run into the situation in the title.
When not to use this skill: unrelated tasks. It covers only the procedure above.
Compatibility
The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.
Details
Browser-based calls to the Wikipedia API were failing while the same requests worked from a server. The fix was adding the origin parameter set to wildcard, which tells the API to send the CORS headers the browser requires. Without it the browser blocks the response even though the request itself succeeded.
Evidence
Source: From a freeCodeCamp forum thread. Browser-based calls to the Wikipedia API were failing while the same requests worked from a server. The fix was adding the origin parameter set to wildcard, which tells the API to send the CORS headers the browser requires. Without it the browser blocks the response even though the request itself succeeded.
Verified resolution: If your Wikipedia API call works in curl but fails in the browser, add the origin wildcard parameter. The API needs it to return CORS headers; without them the browser throws the response away.
Source URL: https://forum.freecodecamp.org/t/wikipedia-search-help/156876
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_vPXxJvCIsC0xUNU20X6ZEQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Wikipedia API: browser calls need origin=* <span>— Vectle</span></a>