Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Ways to set iframe content

I've a scenario where a service (Read as fetchDomainForUser() in code snippet below) is used to create a URL which is used in iframe.

App allow domains by adding CSP headers - frame-src but there are many domains that are possible. Whitelisting any domain is not possible.

Is it possible to load '.aspx' content outside of iFrame, and then add content to iframe?

const [contentWindow, setContentWindow] = React.useState<Window | null>(null);
const iFrameUrl = `${fetchDomainForUser()}/solution.aspx`; // fetchDomainForUser() provides domain dynamically
         
React.useEffect(() => {
            if (contentWindow) {
                (async (): Promise<void> => {
                    const token = fetchToken();

                    const form = contentWindow.document.createElement('form');
    
                    form.setAttribute('action', iframeUrl);
                    form.setAttribute('method', 'POST');
    
                    const accessToken = contentWindow.document.createElement('input');
                    accessToken.setAttribute('type', 'hidden');
                    accessToken.setAttribute('name', 'access_token');
                    accessToken.setAttribute('value', token || '');
                    form.appendChild(accessToken);
    
                    contentWindow.document.body.appendChild(form);
    
                    form.submit();
                })().catch(() => {
                
                });
            }
        }, [contentWindow, iframeUrl]);

const onIFrameRef = React.useCallback((iframeElement: HTMLIFrameElement | null) => {
    setContentWindow((iframeElement && iframeElement.contentWindow) || null);
}, []);

return <iframe width={size.width} height={size.height} style={iframeStyle} ref={onIFrameRef} />;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!