Steps to replicate the issue (include links if applicable):
- Create a PatchDemo wiki and check the "Proxy articles from wikipedia.org" checkbox (or use the wiki I created with this setting)
- On this wiki, switch the skin to Vector-2022
- Type something in the search bar
Credit to @EUdoh-WMF for finding this bug originally.
What happens?: No results appear. The following error message appears in the console:
Access to fetch at 'https://en.wikipedia.org/wikis/8c8ae6a9ba/w/rest.php/v1/search/title?q=m&limit=10' from origin 'https://patchdemo.wmflabs.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. GET https://en.wikipedia.org/wikis/8c8ae6a9ba/w/rest.php/v1/search/title?q=m&limit=10 net::ERR_FAILED 200
What should have happened instead?: Results from Wikipedia (as opposed to from the local wiki) should appear
Software version (skip for WMF-hosted wikis like Wikipedia):
Other information (browser name/version, screenshots, etc.):
The CORS error is misleading. What's really going wrong here is that the request URL is https://en.wikipedia.org/wikis/8c8ae6a9ba/w/rest.php/v1/search/title?q=m&limit=10 , but this should be https://en.wikipedia.org/w/rest.php/v1/search/title?q=m&limit=10 , without the /wikis/8c8ae6a9ba part.
This happens because the way $wgVectorSearchHost is used in restSearchClient.js assumes that the local wiki's wgScriptPath is the same as the target wiki's. But that's not the case when connecting a PatchDemo wiki to a production wiki. I suggest changing the $wgVectorSearchHost setting to take a full URL to rest.php, rather than just a domain name, and renaming it accordingly.