function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lakshmi Priya 42Lakshmi Priya 42 

Failed to load resource: the server responded with a status of 500 (Server Error) - strict-origin-when-cross-origin Error in Salesforce

Requirement Is from an external URL we will get a PDF and have to download that PDF (VFPage).
Apex Code :
HTTPResponse response = Continuation.getResponse(reqLabel); if((response.getStatusCode() != 200 && response.getBody().LEFT(10) != '"fault"') || (response.getStatusCode() == 200 && response.getBody().LEFT(10).contains('"fault"'))) { faultObj = PartnerInvoiceServiceUtility.parsePDFResponse(response.getBody()); System.debug('faultobj '+faultobj); } if(faultObj == null) { Map<String,object> lst_JsonParse = (Map<String,object>)Json.deserializeUntyped(response.getBody()); string invoicePDFURL = (string)(lst_JsonParse.get('invoicePdfUrl')); system.debug('invoicePDFURL> ' + invoicePDFURL); Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(invoicePDFURL); req.setMethod('GET'); req.setHeader('Content-Type', 'application/pdf'); //Now Send HTTP Request system.debug('retFile req ' + req); HttpResponse res = h.send(req); system.debug('retFile response ' + res); system.debug('retFile response body ' + res.getBody()); invoicePDF = EncodingUtil.base64Encode(res.getBodyAsBlob()); // Passing this to VF Page system.debug('invoicePDF > ' + invoicePDF); pdfGenerated = true; //Passing this to VF Page
VF Page
<apex:outputPanel id="dummyPanel"> {!invoicePDF}
<script> console.log('In Dummy Panel...'); var isPDFGenergated = {!pdfGenerated}; if(isPDFGenergated){ debugger; console.log('PDF Genrated Flag: True'); var invoiceBlob = '{!invoicePDF}'; exportActualFileToPDF2('download'); $jq('#pdfError').hide(); console.log('hiding spinner now'); hideSpinner(); } if('{!system_pdferrormessage}'!= null && '{!system_pdferrormessage}' !='') { console.log('Exception: System Error ' + '{!system_pdferrormessage}'); $jq('#pdfError').show(); $jq('#pdfError').html('{!system_pdferrormessage}'); } </script>
On rerender in VF page, we are calling dummy panel function. But rerender is not happening and getting "Failed to load resource: the server responded with a status of 500 (Server Error)" and Status Code: 500 Server Error Referrer-Policy: strict-origin-when-cross-origin
Ways followed to fix this error:
Whitelisted the URL getting from external in CORS
Also created remote site settings for that URL
Nothing fixed our issue

User-added image
SwethaSwetha (Salesforce Developers) 
HI ,

Adding to above, can you ensure the HTTP header size does not exceed the limit of 8 KB.

Reference: https://help.salesforce.com/articleView?id=000354235&language=en_US&mode=1&type=1