This repository was archived by the owner on May 28, 2026. It is now read-only.
T411447: Fix the CORS error when fetching https://ocr.wmcloud.org/models.json#166
Merged
Merged
Conversation
Member
|
Sorry, it might not have been obvious in the task, but it's the Wikisource extension (for MediaWiki) that is making the request through MediaWiki. No change is needed to the tool as far as I know. |
Contributor
Author
|
@samwilson |
Member
|
Ah great, yes I see now! Makes sense. I'll try to review these tomorrow. Thanks for working on it all! |
samwilson
reviewed
Mar 5, 2026
samwilson
left a comment
Member
There was a problem hiding this comment.
Looks great! Just a couple of little comments.
82982b8 to
899d4d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Phabricator Task - T411447
Related Gerrit Patch - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikisource/+/1247993
This PR fixes the CORS error when fetching https://ocr.wmcloud.org/models.json from inside the Wikisource extension.
I attempted to fetch https://ocr.wmcloud.org/models.json directly from the frontend. However, because this file is served as a static asset by nginx (not by Symfony/PHP), it did not include the required Access-Control-Allow-Origin header, resulting in a CORS error in browsers.
To resolve this, the PR introduces a new Symfony route
/api/modelsthat reads and returns the contents of models.json with the correct CORS headers. This ensures the model data is accessible to the frontend, matches the expected data structure, and is served with the necessary CORS headers, while leaving the static file untouched.