Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/azanumer/wp-rest-cors/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
Control Cross-Origin Resource Sharing for the WordPress REST API — an allow-list of origins, optional credentials, and proper OPTIONS preflight handling, so your decoupled front end or mobile app can call the API safely.
Features
- Origin allow-list — one origin per line under Settings → REST CORS. Exact matches, the catch-all
*for a public API, and subdomain wildcards likehttps://*.example.com. - Credentials done right —
Access-Control-Allow-Credentialsis only sent for specific origins, never for*(browsers ignore credentials with a wildcard anyway). - Preflight handling — OPTIONS requests from allowed origins are answered directly from
rest_pre_dispatchwith Allow-Methods, Allow-Headers and Max-Age, before WordPress routes them. - No CORS for anyone else — requests without an Origin header, or from an origin not on the list, get no CORS headers at all.
- Vary: Origin — sent with every CORS response so shared caches don't serve one origin's headers to another.
- Filter —
wrc_allowed_originsoverrides the allow-list in code.
Installation
- Upload the
wp-rest-corsfolder to/wp-content/plugins/. - Activate the plugin through Plugins in WordPress admin.
- Add your front-end origin(s) under Settings → REST CORS.
Notes
- CORS is a browser protection, not authentication: this plugin does not make the REST API public or private — it only tells browsers which origins may read responses. Keep using nonces / application passwords for auth.
X-WP-Nonceis in the default allowed-headers list so cookie-authenticated requests from your front end keep working.
Uninstall
Deleting the plugin removes the wrc_settings option.
License
MIT — see LICENSE.