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

Cors issue only on token validation #224

Open
jeanrinvil opened this issue Sep 7, 2021 · 1 comment
Open

Cors issue only on token validation #224

jeanrinvil opened this issue Sep 7, 2021 · 1 comment

Comments

@jeanrinvil
Copy link

I'm using your plugin with my ionic app

When I use the /jwt-auth/v1/token/validate , I got a cors problem
However, /jwt-auth/v1/token/ seems to work well

I already put this on my htaccess :

RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

and enable cors in my wp-config :

define('JWT_AUTH_CORS_ENABLE', true);

What I need to check ?

@paulando
Copy link

paulando commented Oct 2, 2023

Had the same issue. For me the problem was with setting up headers.

So instead of this:

const response = await fetch(`${wpRestApi}/jwt-auth/v1/token/validate`, {
    headers: {
        'Authorization': `Bearer ${token}`,
    },
    method: "POST",
});

Did this:

const headers = new Headers({
    'Authorization': `Bearer ${token}`,
});

const response = await fetch(`${wpRestApi}/jwt-auth/v1/token/validate`, {
    headers,
    method: "POST",
});

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