No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
-
Heyo!
I’ve ran into this issue after updating the JWT token plugin today. Despite being configured according to the documentation and working just fine all the months before now I’m getting the following CORS error when trying to access any endpoint of the WP REST API.
Access to fetch at 'https://120sek.schuelerwettbewerb.com/wp-json/wp/v2/posts' from origin 'https://localhost:3000' 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.
The actual url has been altered for privacy reasons.
When checking the headers there seems to be a bunch of stuff once I activate the plugin.
Before:
- access-control-allow-credentials: true
- access-control-allow-headers: Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type
- access-control-allow-methods: OPTIONS, GET, POST, PUT, PATCH, DELETE
- access-control-allow-origin: https://localhost:3000
- access-control-expose-headers: X-WP-Total, X-WP-TotalPages, Link
- allow: GET
- content-type: application/json; charset=UTF-8
- date: Wed, 08 Feb 2023 12:30:35 GMT
- link: <https://120sek.de/schuelerwettbewerb/wp-json/wp/v2/posts?page=2>; rel=”next”
- server: Apache
- vary: Origin
- x-content-type-options: nosniff
- x-robots-tag: noindex
- x-wp-total: 30
- x-wp-totalpages: 3
After activation:
- access-control-allow-headers: Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type
- access-control-expose-headers: X-WP-Total, X-WP-TotalPages, Link
- content-type: application/json; charset=UTF-8
- date: Wed, 08 Feb 2023 12:27:47 GMT
- link: <https://120sek.de/schuelerwettbewerb/wp-json/>; rel=”https://api.w.org/”
- server: Apache
- x-content-type-options: nosniff
- x-robots-tag: noindex
- Request Headers
This is my current .htaccess config:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1] </IfModule>
All help is greatly appreciated!
- The topic ‘No ‘Access-Control-Allow-Origin’ header is present on the requested resource.’ is closed to new replies.