Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda