Skip to content

Commit

Permalink
Push changes to live site (#581)
Browse files Browse the repository at this point in the history
* refactor: simplify public route redirection by using template_redirect (#575)

* Update API Router `import` in Auth Docs (#580)

* doc: (#519) adding examples for getStaticPaths

* Update API Router auth import docs

* Update API Router imports to use `@faustjs/core/api`

Co-authored-by: William Johnston <will@wwj.dev>

Co-authored-by: Andrew Matthews <andrew.matthews@wpengine.com>
Co-authored-by: William Johnston <will@wwj.dev>
  • Loading branch information
3 people committed Oct 14, 2021
1 parent 2563121 commit eacadf8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/next/guides/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Before you get started with implementing an authentication strategy, you'll need

```ts title=src/pages/api/faust/[[...route]].ts
import 'faust.config';
import { apiRouter } from '@faustjs/core';
import { apiRouter } from '@faustjs/core/api';

export default apiRouter;
```
Expand Down
2 changes: 1 addition & 1 deletion docs/next/guides/post-page-previews.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Next, you will need to create the `apiRouter`. This sets up the Faust.js API end

```ts
import 'faust.config';
import { apiRouter } from '@faustjs/core';
import { apiRouter } from '@faustjs/core/api';

export default apiRouter;
```
Expand Down
4 changes: 2 additions & 2 deletions docs/next/reference/api-router.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Now, add the following content to your newly created `[[...route]].ts` file:

```tsx title="src/pages/api/faust/[[...route]].ts"
import 'faust.config';
import { apiRouter } from '@faustjs/core';
import { apiRouter } from '@faustjs/core/api';

export default apiRouter;
```
Expand Down Expand Up @@ -69,7 +69,7 @@ Finally, the content of `src/pages/api/headless/[[...route]].ts` would be:

```ts title="src/pages/api/headless/[[...route]].ts"
import 'faust.config';
import { apiRouter } from '@faustjs/core';
import { apiRouter } from '@faustjs/core/api';

export default apiRouter;
```
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/server/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
* @example ```ts
* // filename: pages/api/faust/[[...route]].ts
* import 'faust.config';
* import { apiRouter } from '@faustjs/core';
* import { apiRouter } from '@faustjs/core/api';
*
* export default apiRouter;
* ```
Expand Down
19 changes: 4 additions & 15 deletions plugins/wpe-headless/includes/deny-public-access/callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,20 @@
exit;
}

add_action( 'parse_request', 'wpe_headless_deny_public_access', 99 );
add_action( 'template_redirect', 'wpe_headless_deny_public_access', 99 );
/**
* Redirects non-API requests for public URLs to the specified front-end URL.
*
* @param object $query The current query.
*
* @return void
*/
function wpe_headless_deny_public_access( $query ) {
if ( ! wpe_headless_is_redirects_enabled() ) {
function wpe_headless_deny_public_access() {
if ( ! wpe_headless_is_redirects_enabled() || is_customize_preview() ) {
return;
}

$frontend_uri = wpe_headless_get_setting( 'frontend_uri' );

if (
defined( 'DOING_CRON' ) ||
defined( 'REST_REQUEST' ) ||
is_admin() ||
is_customize_preview() ||
( function_exists( 'is_graphql_http_request' ) && is_graphql_http_request() ) || // From https://wordpress.org/plugins/wp-graphql/.
! empty( $query->query_vars['rest_oauth1'] ) || // From https://oauth1.wp-api.org/.
! property_exists( $query, 'request' ) ||
! $frontend_uri
) {
if ( ! $frontend_uri ) {
return;
}

Expand Down

1 comment on commit eacadf8

@atlas-by-wp-engine
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch main was deployed successfully
Your environment Production of app faustjs-site was successfully updated
View build logs: https://my.wpengine.com/atlas#/faustjs-site/cwa4v7z4d1u9vi7qw7hythg2/8lza53kwxixrfhl87u72pdha
View your environment URL: https://faustjs.org

Please sign in to comment.