Skip to content

Commit

Permalink
fix: WPE_HEADLESS_SECRET to WP_HEADLESS_SECRET (#134)
Browse files Browse the repository at this point in the history
The WPE_ prefix is reserved for env vars on the
WP Engine hosting platform, so users will not
be able to create vars with this name.
  • Loading branch information
nickcernis authored Feb 10, 2021
1 parent 9e3ac37 commit 724d076
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Eager to try out the Headless Framework? Here's how you can get started:
4. Create a new Next.js app from our [getting-started project](https://github.com/wpengine/headless-framework/tree/canary/examples/getting-started): `npx create-next-app -e https://github.com/wpengine/headless-framework/tree/canary --example-path examples/getting-started --use-npm`
6. `cp .env.local.sample .env.local`
7. Populate `WORDPRESS_URL` in `.env.local` with the full URL to your WordPress site, including the `http://` or `https://` prefix.
8. Populate `WPE_HEADLESS_SECRET` in `.env.local` with the secret key found at Settings → Headless in your WordPress admin area.
8. Populate `WP_HEADLESS_SECRET` in `.env.local` with the secret key found at Settings → Headless in your WordPress admin area.
9. `cd my-app && npm run dev`

➡️ [Learn more about getting started](/docs/getting-started/)
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This config file is where you’ll set the WordPress URL and secret key that tie
WORDPRESS_URL=http://yourwpsite.com
# Plugin secret found in WordPress Settings->Headless
WPE_HEADLESS_SECRET=YOUR_PLUGIN_SECRET
WP_HEADLESS_SECRET=YOUR_PLUGIN_SECRET
```

Now you’re ready to run the app!
Expand Down
2 changes: 1 addition & 1 deletion docs/previews/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ We need to let the frontend know about our WordPress instance. The framework exp
NEXT_PUBLIC_WORDPRESS_URL=http://yourwpsite.com

# Plugin secret found in WordPress Settings->Headless
WPE_HEADLESS_SECRET=YOUR_PLUGIN_SECRET
WP_HEADLESS_SECRET=YOUR_PLUGIN_SECRET

# Location of the auth handler endpoint
NEXT_PUBLIC_AUTHORIZATION_URL=/api/authorize
Expand Down
2 changes: 1 addition & 1 deletion examples/getting-started/.env.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ WORDPRESS_URL=http://yourwpsite.com
# NEXT_PUBLIC_WORDPRESS_URL=http://yourwpsite.com

# Plugin secret found in WordPress Settings->Headless
WPE_HEADLESS_SECRET=YOUR_PLUGIN_SECRET
WP_HEADLESS_SECRET=YOUR_PLUGIN_SECRET
2 changes: 1 addition & 1 deletion examples/preview/.env.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ WORDPRESS_URL=http://yourwpsite.com
# NEXT_PUBLIC_WORDPRESS_URL=http://yourwpsite.com

# Plugin secret found in WordPress Settings->Headless
WPE_HEADLESS_SECRET=YOUR_PLUGIN_SECRET
WP_HEADLESS_SECRET=YOUR_PLUGIN_SECRET
4 changes: 2 additions & 2 deletions packages/headless/src/auth/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const AUTH_URL = trimTrailingSlash(
'/api/auth/wpe-headless',
);

const API_CLIENT_SECRET = process.env.WPE_HEADLESS_SECRET;
const API_CLIENT_SECRET = process.env.WP_HEADLESS_SECRET;

if (!API_CLIENT_SECRET && isServerSide()) {
throw new Error(
'WPE_HEADLESS_SECRET environment variable is not set. Please set it to your WPGraphQL endpoint if you wish to use authenticated API calls.',
'WP_HEADLESS_SECRET environment variable is not set. Please set it to your WPGraphQL endpoint if you wish to use authenticated API calls.',
);
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/wpe-headless/includes/auth/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ function wpe_headless_decrypt( $value ) {
* @return string The default key.
*/
function wpe_headless_get_default_key() {
if ( defined( 'WPE_HEADLESS_SECRET_KEY' ) && WPE_HEADLESS_SECRET_KEY ) {
return WPE_HEADLESS_SECRET_KEY;
if ( defined( 'WP_HEADLESS_SECRET_KEY' ) && WP_HEADLESS_SECRET_KEY ) {
return WP_HEADLESS_SECRET_KEY;
}

if ( defined( 'AUTH_KEY' ) && AUTH_KEY ) {
Expand Down

0 comments on commit 724d076

Please sign in to comment.