diff --git a/lib/router/router.js b/lib/router/router.js index f03107bf..8eedd6ad 100644 --- a/lib/router/router.js +++ b/lib/router/router.js @@ -4,7 +4,7 @@ import { parse, format } from 'url' import EventEmitter from '../EventEmitter' import shallowEquals from '../shallow-equals' import PQueue from '../p-queue' -import { loadGetInitialProps, getURL } from '../utils' +import { loadGetInitialProps, getURL, warn, execOnce } from '../utils' import { _notifyBuildIdMismatch, _rewriteUrlForNextExport } from './' export default class Router { @@ -185,7 +185,9 @@ export default class Router { } changeState (method, url, as, options = {}) { - if (method !== 'pushState' || getURL() !== as) { + if (window.frameElement) { + execOnce(warn)(`Warning: You're using Next.js inside an iFrame. Browser history is disabled.`) + } else if (method !== 'pushState' || getURL() !== as) { window.history[method]({ url, as, options }, null, as) } }