Preflight (OPTION method) requests are redirected to the default 403 Forbidden page

Username (e.g. epiz_XXX) or Website URL

epiz_29773436

Error Message

Access to fetch at ‘https://wp.softhardsystem.com/graphql’ from origin ‘http://localhost:8000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: Redirect is not allowed for a preflight request.

Other Information

I am trying to fetch data and send data to the WP REST & WPGraphQL API. The browser can successfully fetch the data all the time except when the request is applicable for a preflight request. Because when the browser sends the preflight request to the server, the server redirects the request to the default 403 forbidden page (403 Forbidden - InfinityFree). Why the server is redirecting the request to the 403 forbidden page and how can I remove the redirect?

I’m a bit confused, but maybe this?

2 Likes

Hmm… I think you are right. But what is described on the topic is partially true. Because I am able to achieve many things described in the topic. And another question, the browser executing fetch requests definitely supports JS and accepts cookies. So, why some requests are blocked (for example, preflight (OPTIONS method)) and some aren’t?

Your browser does support Javascript, but doesn’t execute it on XHR requests. So your code will just get back the HTML response with the Javascript code, not the result of what happens after the Javascript is executed.

Also, third party cookie blocking may be an issue.

Then I think it executes the JavaScript on GET and POSTS requests (and maybe some other methods too) but not on OPTIONS requests.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.