Skip to content
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

Mutations with authorization header gives 500 error #660

Closed
vorasudh opened this issue Oct 5, 2022 · 5 comments
Closed

Mutations with authorization header gives 500 error #660

vorasudh opened this issue Oct 5, 2022 · 5 comments

Comments

@vorasudh
Copy link

vorasudh commented Oct 5, 2022

Describe the bug
I am facing issues when a logged-in customer is trying to add to cart or checkout. I am using WPGraphQL JWT Authentication for authentication. I receive authToken, refreshToken and sessionToken. When I try to make any mutation with the authorization and woocommerce-session header, the call fails with error code 500 with this message:

<p>There has been a critical error on this website.</p><p><a href=\"https://wordpress.org/support/article/faq-troubleshooting/\">Learn more about troubleshooting WordPress.</a></p>.

Unfortunately, enabling debugging does not provide any logs in response to the mutation.

So basically a logged-in user cannot add a product to a cart (mutation: addToCart) and cannot checkout (mutation: checkout). I have looked at many previous issues (#88, #147, #297, #320), but nothing is solving my problem here. Maybe I missed some configuration here. Can someone please guide me?

Plugin Versions

  • WooGraphQL Version: 0.11.2
  • WPGraphQL Version: 1.11.1
  • WordPress Version: 6.0.2
  • WooCommerce Version: 6.9.4
@kidunot89
Copy link
Member

@vorasudh What version of WPGraphQL JWT Authentication are you using?

@vorasudh
Copy link
Author

vorasudh commented Oct 6, 2022

@kidunot89 I am using v0.5.2 of WPGraphQL JWT Authentication

@kidunot89
Copy link
Member

@vorasudh Are you testing this in a GraphQL client?

@vorasudh
Copy link
Author

vorasudh commented Oct 7, 2022

@kidunot89 Yes, i am using Apollo client in my NextJS project.

@vorasudh
Copy link
Author

After days of debugging, it turns out that my .htaccess file already had a configuration to redirect auth header so WP can access it. And I was adding it again - SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1.

Once I removed SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1, it just worked nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants