Skip to content

Commit 281d2d7

Browse files
authored
Merge pull request #100 from strapi/fix/live-preview
Fix live previews by using strapi-encode-source-maps in client headers
2 parents 5d44b99 + a5e4ca2 commit 281d2d7

File tree

6 files changed

+962
-308
lines changed

6 files changed

+962
-308
lines changed

next/components/dynamic-zone/hero.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ export const Hero = ({
3636
as="h1"
3737
className="text-4xl md:text-4xl lg:text-8xl font-semibold max-w-7xl mx-auto text-center mt-6 relative z-10 py-6"
3838
>
39-
{heading.substring(0, heading.lastIndexOf(' '))}{' '}
40-
<Cover>{heading.split(' ').pop()}</Cover>
39+
{heading}
4140
</Heading>
4241
<Subheading className="text-center mt-2 md:mt-6 text-base md:text-xl text-muted max-w-3xl mx-auto relative z-10">
4342
{sub_heading}

next/lib/strapi/client.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ export class StrapiError extends Error {
1313
}
1414
}
1515

16-
const createClient = (config?: Omit<Config, 'baseURL'>) =>
17-
strapi({
16+
const createClient = (config?: Omit<Config, 'baseURL'>, isDraftMode: boolean = false) => {
17+
return strapi({
1818
baseURL: `${process.env.NEXT_PUBLIC_API_URL ?? ''}/api`,
19+
headers: {
20+
"strapi-encode-source-maps": isDraftMode ? "true" : "false",
21+
...config?.headers,
22+
},
1923
...config,
2024
});
25+
}
2126

2227
/**
2328
* Fetches a collection type from Strapi.
@@ -32,7 +37,7 @@ export async function fetchCollectionType<T = API.Document[]>(
3237
const { isEnabled: isDraftMode } = await draftMode();
3338

3439
try {
35-
const { data } = await createClient(config)
40+
const { data } = await createClient(config, isDraftMode)
3641
.collection(collectionName)
3742
.find({
3843
...options,
@@ -62,7 +67,7 @@ export async function fetchSingleType<T = API.Document>(
6267
const { isEnabled: isDraftMode } = await draftMode();
6368

6469
try {
65-
const { data } = await createClient(config)
70+
const { data } = await createClient(config, isDraftMode)
6671
.single(singleTypeName)
6772
.find({
6873
...options,
@@ -93,7 +98,7 @@ export async function fetchDocument<T = API.Document>(
9398
const { isEnabled: isDraftMode } = await draftMode();
9499

95100
try {
96-
const { data } = await createClient(config)
101+
const { data } = await createClient(config, isDraftMode)
97102
.collection(collectionName)
98103
.findOne(documentId, {
99104
...options,

next/lib/strapi/fetchContentType.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

next/yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,10 @@ __metadata:
687687
languageName: node
688688
linkType: hard
689689

690-
"@next/env@npm:15.5.7":
691-
version: 15.5.7
692-
resolution: "@next/env@npm:15.5.7"
693-
checksum: 10c0/f92d99e5fa3516c6b7699abafd9bd813f5c1889dd257ab098f1b71f93137f5e4f49792e22f6dddf8a59efcb134e8e84277c983ff88607b2a42aac651bfde78ea
690+
"@next/env@npm:15.5.8":
691+
version: 15.5.8
692+
resolution: "@next/env@npm:15.5.8"
693+
checksum: 10c0/77a33346f6350e8e68d4f308d9a40301e1c681b4b31f9ea2e2da15773433fa7e781b8351092bbf278bed07cee7a50f8351cbcb5107f999397d45c4959fc6ca0d
694694
languageName: node
695695
linkType: hard
696696

@@ -4880,11 +4880,11 @@ __metadata:
48804880
languageName: node
48814881
linkType: hard
48824882

4883-
"next@npm:15.5.7":
4884-
version: 15.5.7
4885-
resolution: "next@npm:15.5.7"
4883+
"next@npm:15.5.8":
4884+
version: 15.5.8
4885+
resolution: "next@npm:15.5.8"
48864886
dependencies:
4887-
"@next/env": "npm:15.5.7"
4887+
"@next/env": "npm:15.5.8"
48884888
"@next/swc-darwin-arm64": "npm:15.5.7"
48894889
"@next/swc-darwin-x64": "npm:15.5.7"
48904890
"@next/swc-linux-arm64-gnu": "npm:15.5.7"
@@ -4935,7 +4935,7 @@ __metadata:
49354935
optional: true
49364936
bin:
49374937
next: dist/bin/next
4938-
checksum: 10c0/baf5b9f42416c478702b3894479b3d7862bc4abf18afe0e43b7fc7ed35567b8dc6cb76cd94906505bab9013cb8d0f3370cdc0451c01ec15ae5a638d37b5ba7c7
4938+
checksum: 10c0/9f7732bc5782ec9701774cc0ba4d209e43d0d82611af3340db3144e7ac3fb4e39556ae8b37a8a4679b6e8754c6764814217c6fc15ddb2538a6e4ebe6a4aa42a9
49394939
languageName: node
49404940
linkType: hard
49414941

@@ -4972,7 +4972,7 @@ __metadata:
49724972
fuzzy-search: "npm:^3.2.1"
49734973
mini-svg-data-uri: "npm:^1.4.4"
49744974
negotiator: "npm:^0.6.3"
4975-
next: "npm:15.5.7"
4975+
next: "npm:15.5.8"
49764976
next-view-transitions: "npm:^0.2.0"
49774977
postcss: "npm:^8"
49784978
qs: "npm:^6.14.0"

strapi/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"typescript": "^5"
2020
},
2121
"dependencies": {
22-
"@strapi/plugin-cloud": "5.30.0",
22+
"@strapi/plugin-cloud": "^5.30.0",
2323
"@strapi/plugin-seo": "^2.0.4",
24-
"@strapi/plugin-users-permissions": "5.30.0",
25-
"@strapi/strapi": "5.30.0",
24+
"@strapi/plugin-users-permissions": "^5.30.0",
25+
"@strapi/strapi": "^5.30.0",
2626
"better-sqlite3": "11.7.0",
2727
"patch-package": "^8.0.0",
2828
"pluralize": "^8.0.0",

0 commit comments

Comments
 (0)