Skip to content

Commit 8bcd19b

Browse files
rotexhawkwardpeet
authored andcommitted
feat(gatsby-source-wordpress): add jwt_base_path option (#11425)
## Description Removes hardcoded JWT token path in gatsby-source-wordpress and passes it in auth options, to support other Wordpress JWT plugins. Test Passed and the functionality works locally.
1 parent 64db1b3 commit 8bcd19b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/gatsby-source-wordpress/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ module.exports = {
9191
wpcom_pass: process.env.WORDPRESS_PASSWORD,
9292

9393
// If you use "JWT Authentication for WP REST API" (https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
94+
// or (https://github.com/jonathan-dejong/simple-jwt-authentication) requires jwt_base_path, path can be found in wordpress wp-api.
9495
// plugin, you can specify user and password to obtain access token and use authenticated requests against wordpress REST API.
9596
jwt_user: process.env.JWT_USER,
9697
jwt_pass: process.env.JWT_PASSWORD,
98+
jwt_base_path: "/jwt-auth/v1/token" # Default - can skip if you are using https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/
9799
},
98100
// Set verboseOutput to true to display a verbose output on `npm run develop` or `npm run build`
99101
// It can help you debug specific API Endpoints problems.

packages/gatsby-source-wordpress/src/fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async function getWPCOMAccessToken(_auth) {
212212
*/
213213
async function getJWToken(_auth, url) {
214214
let result
215-
let authUrl = `${url}/jwt-auth/v1/token`
215+
let authUrl = `${url}${_auth.jwt_base_path || `/jwt-auth/v1/token`}`
216216
try {
217217
const options = {
218218
url: authUrl,

0 commit comments

Comments
 (0)