File tree Expand file tree Collapse file tree 5 files changed +13
-15
lines changed
Expand file tree Collapse file tree 5 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ fileignoreconfig:
1111- filename: src/sdk/utils.ts
1212 checksum: 00fb0674684ede99467f5d77012d92136481d54c75894768646e58703ae0fa5a
1313- filename: src/sdk/entry.ts
14- checksum: 42de7b871970e732d243f1183b5eacf1ebe36f3dc0560afa6cc257107f696c25
14+ checksum: 33b8aa8ad61a79911b22c61b418094034b308ca96bdebdc2619398337433fa1d
1515version: "1.0"
Original file line number Diff line number Diff line change 11MIT License
22
3- Copyright (c) 2024 Contentstack
3+ Copyright (c) 2025 Contentstack
44
55Permission is hereby granted, free of charge, to any person obtaining a copy
66of this software and associated documentation files (the "Software"), to deal
Original file line number Diff line number Diff line change @@ -2,8 +2,9 @@ import { getEntry, getEntryByUrl } from "../sdk/entry";
22import { addEditableTags } from "@contentstack/utils" ;
33import { FooterRes , HeaderRes } from "../typescript/response" ;
44import { BlogPostRes , Page } from "../typescript/pages" ;
5+ import { ENV } from "../sdk/utils" ;
56
6- const liveEdit = import . meta . env . VITE_CONTENTSTACK_LIVE_EDIT_TAGS === "true" ;
7+ const liveEdit = ENV . LIVE_EDIT_TAGS === "true" ;
78
89export const getHeaderRes = async ( ) : Promise < HeaderRes > => {
910 const response = ( await getEntry ( {
Original file line number Diff line number Diff line change 55 customHostUrl ,
66 initializeContentStackSdk ,
77 isValidCustomHostUrl ,
8+ ENV ,
89} from "./utils" ;
910
1011type GetEntry = {
@@ -20,14 +21,8 @@ type GetEntryByUrl = {
2021 jsonRtePath : string [ ] | undefined ;
2122} ;
2223
23- // Get environment variables using Vite's import.meta.env
24- const VITE_CONTENTSTACK_API_HOST = import . meta. env . VITE_CONTENTSTACK_API_HOST ;
25- const VITE_CONTENTSTACK_API_KEY = import . meta. env . VITE_CONTENTSTACK_API_KEY ;
26- const VITE_CONTENTSTACK_APP_HOST = import . meta. env . VITE_CONTENTSTACK_APP_HOST ;
27-
28- const customHostBaseUrl = VITE_CONTENTSTACK_API_HOST ? customHostUrl (
29- VITE_CONTENTSTACK_API_HOST as string
30- ) : "" ;
24+ // Get custom host base URL from ENV.API_HOST
25+ const customHostBaseUrl = ENV . API_HOST ? customHostUrl ( ENV . API_HOST ) : "" ;
3126
3227// SDK initialization
3328const Stack = initializeContentStackSdk ( ) ;
@@ -41,13 +36,13 @@ if (customHostBaseUrl && isValidCustomHostUrl(customHostBaseUrl)) {
4136ContentstackLivePreview . init ( {
4237 //@ts -ignore
4338 stackSdk : Stack ,
44- enable : true ,
39+ enable : ENV . LIVE_PREVIEW === " true" ,
4540 mode : "builder" ,
4641 stackDetails : {
47- apiKey : VITE_CONTENTSTACK_API_KEY ,
42+ apiKey : ENV . API_KEY ,
4843 } ,
4944 clientUrlParams :{
50- host : VITE_CONTENTSTACK_APP_HOST
45+ host : ENV . APP_HOST
5146 }
5247} ) ?. catch ( ( error ) => console . error ( error ) ) ;
5348
Original file line number Diff line number Diff line change 11import { Config , Region , LivePreview , Stack } from "contentstack" ;
22
33// Extract environment variables for easier access and maintenance
4- const ENV = {
4+ export const ENV = {
55 API_KEY : import . meta. env . VITE_CONTENTSTACK_API_KEY as string ,
66 DELIVERY_TOKEN : import . meta. env . VITE_CONTENTSTACK_DELIVERY_TOKEN as string ,
77 ENVIRONMENT : import . meta. env . VITE_CONTENTSTACK_ENVIRONMENT as string ,
@@ -11,6 +11,8 @@ const ENV = {
1111 PREVIEW_TOKEN : import . meta. env . VITE_CONTENTSTACK_PREVIEW_TOKEN as string ,
1212 PREVIEW_HOST : import . meta. env . VITE_CONTENTSTACK_PREVIEW_HOST as string ,
1313 APP_HOST : import . meta. env . VITE_CONTENTSTACK_APP_HOST as string ,
14+ API_HOST : import . meta. env . VITE_CONTENTSTACK_API_HOST as string ,
15+ LIVE_EDIT_TAGS : import . meta. env . VITE_CONTENTSTACK_LIVE_EDIT_TAGS as string ,
1416} ;
1517
1618// basic env validation
You can’t perform that action at this time.
0 commit comments