Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross-domain iframe not hydrating after SSR on devServer #18028

Open
gutofoletto opened this issue Oct 19, 2020 · 5 comments
Open

cross-domain iframe not hydrating after SSR on devServer #18028

gutofoletto opened this issue Oct 19, 2020 · 5 comments
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@gutofoletto
Copy link

gutofoletto commented Oct 19, 2020

Bug report

Describe the bug

It seems that when the app is loaded on a cross-domain iFrame nextJS (dev server) does not hydrate SSR pages / components unless they are visible on the screen.

  • If you run the same project on a "same-domain" website it works as expected.
  • If you remove visibility: hidden or display:none it works on both "cross and same domain" environment.

This behaviour was observed when upgrading from 9.2.0 to 9.2.1 (or greater)

To Reproduce

  1. Clone this repository (there are some instructions on the readme file as well)
  2. Set up your /etc/hosts file and point the domain to your localhost: 127.0.0.1 yourcustomdomain.dev.com
  3. Go to the root folder and run nextJS devServer with yarn dev
  4. Go to the public folder and serve index.html, you could use php local server if you want: php -S 0.0.00:8080
  5. Open the browser and go to http://localhost:8080
  6. Open the browser console and observe the logs
  7. Only the iframe init log will be present and none of the logs from the HomePage will be displayed
  8. The logs from HomePage will be triggered if you press "show" to display the component (removes the visibility: hidden css property)

Expected behavior

It is expected that when using the development server it would hydrate / rerender the components on a cross-domain iframe. Is that right?

Screenshots

ezgif com-gif-maker

System information

  • OS: macOs 10.15.7
  • Browser: Chrome Version 86.0.4240.80
  • Version of Next.js: >= 9.2.1
  • Version of Node.js: 10.16.0
@timneutkens timneutkens added the good first issue Easy to fix issues, good for newcomers label Oct 21, 2020
@ealvarez968
Copy link

Hi, can I take a look at this?

@OriginalJef

This comment was marked as off-topic.

@danwdart
Copy link

This is still reproducible on 12.1.0

@orrymr
Copy link

orrymr commented Nov 28, 2024

I just tried this with the latest Next canary branch, and the problem seems to be resolved:

Peek 2024-11-28 16-46

Darn, I was hoping this would be my first issue (as it's tagged "good first issue").
Oh well :P

@shriekdj
Copy link

@gutofoletto I think this is more of an react's problem than the nextjs's i use suppressHydrationWarning prop to true for not getting issue in react js when using iframe.
But I also created the Seperate Component ( Client Side ) which is by default suppressHydrationWarning

'use client';
import * as React from 'react';

const IframeClient = (
  props: React.JSX.IntrinsicAttributes &
    React.ClassAttributes<HTMLIFrameElement> &
    React.IframeHTMLAttributes<HTMLIFrameElement>,
) => {
  const { suppressHydrationWarning, ...remainingProps } = { ...props };
  return <iframe
    {...remainingProps}
    suppressHydrationWarning={suppressHydrationWarning ? suppressHydrationWarning : true}
  />;
};

export default IframeClient;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

No branches or pull requests

7 participants