File tree 1 file changed +13
-1
lines changed
packages/sanity/src/_internal/cli/server
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -125,9 +125,21 @@ export function decorateIndexWithAutoGeneratedWarning(template: string): string
125
125
* with core-ui.
126
126
*/
127
127
export function decorateIndexWithBridgeScript ( template : string ) : string {
128
+ const sanityEnv = process . env . SANITY_INTERNAL_ENV || 'production'
129
+
130
+ /**
131
+ * The URL to the bridge script is determined by the
132
+ * `SANITY_INTERNAL_ENV` environment variable. So if you deploy
133
+ * a studio to the staging ENV then you'll get the correct script.
134
+ */
135
+ const scriptURL =
136
+ sanityEnv === 'production'
137
+ ? 'https://core.sanity-cdn.com/bridge.js'
138
+ : 'https://core.sanity-cdn.work/bridge.js'
139
+
128
140
return template . replace (
129
141
'</head>' ,
130
- ' <script src="https://core.sanity-cdn.com/bridge.js " async type="module"></script>\n</head>' ,
142
+ ` <script src="${ scriptURL } " async type="module" data-sanity-core ></script>\n</head>` ,
131
143
)
132
144
}
133
145
You can’t perform that action at this time.
0 commit comments