Skip to content

Commit

Permalink
Merge branch 'develop' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Feb 26, 2024
2 parents c818494 + 5396b23 commit 7bc23a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-pugs-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@headstartwp/next": patch
---

Hotfix preview alternative headers
8 changes: 6 additions & 2 deletions packages/next/src/handlers/previewHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable consistent-return */
import { CustomPostType, getSiteByHost, PostEntity } from '@headstartwp/core';
import { getCustomPostType, getHeadlessConfig } from '@headstartwp/core/utils';
import { getCustomPostType, getHeadstartWPConfig } from '@headstartwp/core/utils';
import type { NextApiRequest, NextApiResponse } from 'next';
import { fetchHookData, usePost } from '../data';
import { PreviewData } from './types';
Expand Down Expand Up @@ -138,7 +138,7 @@ export async function previewHandler(
);
const isMultisiteRequest = site !== null && typeof site.sourceUrl === 'string';

const { sourceUrl } = isMultisiteRequest ? site : getHeadlessConfig();
const { sourceUrl, preview } = isMultisiteRequest ? site : getHeadstartWPConfig();

const revision = is_revision === '1';

Expand Down Expand Up @@ -168,6 +168,10 @@ export async function previewHandler(
revision,
authToken: token as string,
},
fetchStrategyOptions: {
alternativePreviewAuthorizationHeader:
preview?.alternativeAuthorizationHeader ?? false,
},
},
);

Expand Down

0 comments on commit 7bc23a0

Please sign in to comment.