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

"Internal server error" without a reason when token expires #171

Open
ltroya-as opened this issue Nov 18, 2022 · 2 comments
Open

"Internal server error" without a reason when token expires #171

ltroya-as opened this issue Nov 18, 2022 · 2 comments

Comments

@ltroya-as
Copy link

Hi guys,

I am receiving an Internal server error when the token expires without any other useful message that helps me identify the error's cause.

E.g:
image

However, if I enable the "Enable GraphQL Debug Mode", it returns the cause (invalid-jwt) of the issue but there is a warning on that option not to allow that on the production environment.
Screenshot:
image

The status code is always 200 for both cases.

Is there anything I can do to receive the error on the production environment when sending an expired token?

@AVert
Copy link

AVert commented Dec 25, 2022

Same

@alvarolog
Copy link

alvarolog commented Jan 24, 2023

Hi, I have been struggling with the same problem and finally a found a possible solution, you can add an action to intercept the token error and send an UserError response instead a WP_Error, so you can read the response in the errors variable

add_action('graphql_before_resolve_field', function () {
    $token = \WPGraphQL\JWT_Authentication\Auth::validate_token();
    if (is_wp_error($token)) {
        throw new \GraphQL\Error\UserError($token->get_error_code());
    }
}, 0);

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

3 participants