Skip to content
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
samwilson merged 1 commit into
wikimedia:mainfrom
okerekechinweotito:models-config
Mar 5, 2026
Merged

T411447: Fix the CORS error when fetching https://ocr.wmcloud.org/models.json#166
samwilson merged 1 commit into
wikimedia:mainfrom
okerekechinweotito:models-config

Conversation

@okerekechinweotito

@okerekechinweotito okerekechinweotito commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

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/models that 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.

@okerekechinweotito okerekechinweotito changed the title T411447: Load models config directly rather than proxying via MediaWiki T411447: Load models config directly rather than proxying via MediaWiki ( Fix the CORS error when fetching https://ocr.wmcloud.org/models.json ) Mar 4, 2026
@samwilson

Copy link
Copy Markdown
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.

@okerekechinweotito okerekechinweotito changed the title T411447: Load models config directly rather than proxying via MediaWiki ( Fix the CORS error when fetching https://ocr.wmcloud.org/models.json ) T411447: Fix the CORS error when fetching https://ocr.wmcloud.org/models.json Mar 4, 2026
@okerekechinweotito

Copy link
Copy Markdown
Contributor Author

@samwilson
Sorry if the PR title was a bit confusing. This PR is to fix the CORS error I get when I call https://ocr.wmcloud.org/models.json from inside the wikisource extension.
I have already made a patch to wikisource (gerrit link attached to this PR description) that enables direct calls to /models.json

@samwilson

Copy link
Copy Markdown
Member

Ah great, yes I see now! Makes sense.

I'll try to review these tomorrow. Thanks for working on it all!

@samwilson samwilson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a couple of little comments.

Comment thread src/Controller/OcrController.php Outdated
Comment thread src/Controller/OcrController.php Outdated
@samwilson samwilson merged commit 1936e77 into wikimedia:main Mar 5, 2026
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants