-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WP-GraphQL refusing connection from NextJS frontend #39
Comments
You probably already solved this issue or found another solution instead. But these are the settings that work for me in development AND production: Go to GraphQL > settings > CORS settings and make sure the following settings are set: Add Site Address to "Access-Control-Allow-Origin" header should be checked. Extend "Access-Control-Allow-Origin” header : Enter the domain of your frontend including protocol. Example: https://example.com/ The following settings should also be enabled: Send site credentials Please note: The Safari browser does not allow you to share cookies across different domains, as these are considered 3rd party and blocked by default. However, if you run WordPress on a subdomain of the domain used for the frontend - cookies will not be blocked. |
I don't see any CORS settings in v1.22.1 of the WPGraphQL plugin. Have these been moved/removed do you think? |
@dgwyer You probably already figured it out, but WPGraphql Cors is a separate plugin |
@MakanaMakesStuff @ronleeson I'm still encoutering this cors issue with next js. WooCommerce v9.1.4 , WP GraphQL V1.3.8, WPGraphQL CORS V2.1 I have this as settings in my apollo config `import { /**
if (session) { return forward(operation); /**
const clientSide = typeof window === "undefined"; // Apollo GraphQL client. export default client; ![]() |
Doing a nextjs app working with wordpress graphql, wordpress is hosted on wpengine. if I'm making simple fetch requests to mysite.com/graphql from the client and including woocommerce session in headers i get this: localhost/:1 Access to fetch at ... from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field woocommerce-session is not allowed by Access-Control-Allow-Headers in preflight response. If there is any way to get around it ? |
In the Cors Settings I have the Add Site Address to "Access-Control-Allow-Origin" header checked and the Extend "Access-Control-Allow-Origin” header set to http://localhost:3000 which is my NextJS frontend.
I also added 'Access-Control-Allow-Origin': 'http://localhost:3000/', to my useSWR fetcher headers but wp-graphql is still refusing the connection.
Any thoughts would greatly be appreciated.
The text was updated successfully, but these errors were encountered: