@@ -1830,19 +1830,6 @@ private async Task<JObject> Exec()
18301830 Dictionary < string , object > headerAll = new Dictionary < string , object > ( ) ;
18311831 Dictionary < string , object > mainJson = new Dictionary < string , object > ( ) ;
18321832
1833- if ( headers != null && headers . Count ( ) > 0 )
1834- {
1835- foreach ( var header in headers )
1836- {
1837- if ( this . ContentTypeInstance . StackInstance . LivePreviewConfig . Enable == true
1838- && this . ContentTypeInstance . StackInstance . LivePreviewConfig . ContentTypeUID == this . ContentTypeInstance . ContentTypeId
1839- && header . Key == "access_token" )
1840- {
1841- continue ;
1842- }
1843- headerAll . Add ( header . Key , ( string ) header . Value ) ;
1844- }
1845- }
18461833 bool isLivePreview = false ;
18471834 if ( this . ContentTypeInstance . StackInstance . LivePreviewConfig . Enable == true
18481835 && this . ContentTypeInstance . StackInstance . LivePreviewConfig . ContentTypeUID == this . ContentTypeInstance . ContentTypeId )
@@ -1859,7 +1846,27 @@ private async Task<JObject> Exec()
18591846
18601847 isLivePreview = true ;
18611848 }
1849+
1850+ if ( headers != null && headers . Count ( ) > 0 )
1851+ {
1852+ foreach ( var header in headers )
1853+ {
1854+ if ( this . ContentTypeInstance . StackInstance . LivePreviewConfig . Enable == true
1855+ && this . ContentTypeInstance . StackInstance . LivePreviewConfig . ContentTypeUID == this . ContentTypeInstance . ContentTypeId
1856+ && header . Key == "access_token"
1857+ && isLivePreview )
1858+ {
1859+ continue ;
1860+ }
1861+ headerAll . Add ( header . Key , ( string ) header . Value ) ;
1862+ }
1863+ }
18621864
1865+ if ( ! isLivePreview && headerAll . ContainsKey ( "preview_token" ) )
1866+ {
1867+ headerAll . Remove ( "preview_token" ) ;
1868+ }
1869+
18631870 mainJson . Add ( "environment" , this . ContentTypeInstance . StackInstance . Config . Environment ) ;
18641871 if ( QueryValueJson != null && QueryValueJson . Count > 0 )
18651872 mainJson . Add ( "query" , QueryValueJson ) ;
0 commit comments