CORS error or empty response when hitting /graphql endpoint #4655
Unanswered
taylorcammack
asked this question in
Q&A
Replies: 1 comment
-
Doubt that anyone else will have had this problem, but in case anyone was curious, the Statamic site we were using was originally set up as V3 was being developed and was (theoretically) being kept up to date with latest config/app changes. In this case, we had up-to-date config, but the $middleware array in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, I'm currently tinkering with a Svelte app and wanted to use a local Statamic site I'd already set up as a data store.
First thing was to resolve CORS; found this Gist and it seemed pretty straight-forward. After updating Valet, I was able to run a simple fetch like this:
For a different section, I have a query that involves hitting the GraphQL endpoint to request data. That looks something like this:
This results in a CORS error.
When I remove the
headers
in the request, it goes through without a CORS error:But the response is empty:
It should be noted that the query seems OK – I'm currently using in the Statamic site and, using Postman, I can hit the same endpoint and query and it returns the expected response.
Things I've tried:
mode
in the request: cors, no-cors, etc.headers
/graphql
endpoint into the cors.php file in my Statamic siteAny ideas? 🙏
Beta Was this translation helpful? Give feedback.
All reactions