Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit f624edb

Browse files
fix: update preview_host calculation to use app_host
1 parent 1398bf4 commit f624edb

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CONTENTSTACK_ENVIRONMENT=your_environment_token
88

99
# Below config options are for enabling live preview/live edit tags for the starter app
1010

11-
CONTENTSTACK_PREVIEW_HOST= rest-preview.contentstack.com
11+
# CONTENTSTACK_PREVIEW_HOST= rest-preview.contentstack.com -- it will be generated runtime from CONTENTSTACK_APP_HOST
1212
CONTENTSTACK_PREVIEW_TOKEN= your_live_preview_token
1313
CONTENTSTACK_APP_HOST=app.contentstack.com
1414
CONTENTSTACK_LIVE_PREVIEW= true

.talismanrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ fileignoreconfig:
22
- filename: .github/workflows/secrets-scan.yml
33
ignore_detectors:
44
- filecontent
5+
- filename: .env.sample
6+
checksum: 5cb7389df244ea0f5c62e6f156ea038d0725e46d52662ca479e671108bdd966b
7+
- filename: setenv.ts
8+
checksum: 243eb74a14fc02eaacd1e632b498387b946b929807ff8687931bb1e530002541
59
version: "1.0"

setenv.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const stackConfig = {
1111
branch: process.env.CONTENTSTACK_BRANCH || 'main',
1212
region: process.env.CONTENTSTACK_REGION || 'us',
1313
};
14+
15+
// Calculate preview_host from app_host if available and preview_host is not explicitly set
16+
const appHost = process.env.CONTENTSTACK_APP_HOST;
17+
const previewHost = process.env.CONTENTSTACK_PREVIEW_HOST ||
18+
(appHost ? appHost.replace('app', 'rest-preview') : undefined);
19+
1420
const environmentFileContent = `
1521
export const environment = {
1622
production: true
@@ -23,7 +29,7 @@ export const Config = {
2329
branch: '${process.env.CONTENTSTACK_BRANCH || 'main'}',
2430
region: '${process.env.CONTENTSTACK_REGION || 'us'}',
2531
preview_token:'${process.env.CONTENTSTACK_PREVIEW_TOKEN}',
26-
preview_host:'${process.env.CONTENTSTACK_PREVIEW_HOST}',
32+
preview_host:'${previewHost}',
2733
api_host:'${process.env.CONTENTSTACK_API_HOST}',
2834
app_host:'${process.env.CONTENTSTACK_APP_HOST}',
2935
live_preview:${process.env.CONTENTSTACK_LIVE_PREVIEW || true}

0 commit comments

Comments
 (0)