I am using react-wp-theme in wordpress the run a react app in wp-engine I am trying to call JWT Authentication for WP-API Login api to authenticate the user it is giving success 200 response but in response data I am getting my index.php file content instead of token
It is working without any issue in local wordpress (running on xampp) when I promoted the code in wp-engine I am getting this issue
I have followed every steps mentioned plugin documentation
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
define('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');
define('JWT_AUTH_CORS_ENABLE', true);
Error I am getting:
<!DOCTYPE html>
<html lang="en">
<head>
<script
src='/wp-content/themes/wpn-react-wp-theme/react-src/node_modules/@devloco/create-
react-wptheme-utils/wpThemeClient.js'>
</script>
<script
src='/wp-content/themes/wpn-react-wp-theme/react-src/node_modules/@devloco/create-react-wptheme-utils/wpThemeErrorOverlay.js'>
</script>
<script>
wpThemeClient.start("ws", "127.0.0.1", "8090");
</script>
<meta charset="utf-8" />
<link rel="shortcut icon" href="/wp-content/themes/wpn-react-wp-theme/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-wptheme" />
<link rel="apple-touch-icon" href="/wp-content/themes/wpn-react-wp-theme/logo192.png" />
<link rel="manifest" href="/wp-content/themes/wpn-react-wp-theme/manifest.json" />
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65"
crossorigin="anonymous" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600;700;800;900&display=swap"
<title>Word Prev</title>
<link href="/wp-content/themes/wpn-react-wp-theme/static/css/main.chunk.css?
76e963b2483ab6ad865c" rel="stylesheet">
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<script src="/wp-content/themes/wpn-react-wp-theme/static/js/bundle.js?76e963b2483ab6ad865c"></script>
<script src="/wp-content/themes/wpn-react-wp-theme/static/js/0.chunk.js?76e963b2483ab6ad865c"></script>
<script src="/wp-content/themes/wpn-react-wp-theme/static/js/main.chunk.js?76e963b2483ab6ad865c"></script>
</body>
</html>
API call from react-wp-theme
axios.post('/wp-json/jwt-auth/v1/token', {
username: username,
password: password,
})
.then((response) => {
const token = response.data.token;
localStorage.setItem('token', token);
})
.catch((error) => {
console.error(error);
});
Wpengine no longer supports configs in .htacess.
Talk to WPengine support and they will guide you to create web rules so that jwt works in WPengine.