Commit b8f189f2 authored by Henric Malmberg's avatar Henric Malmberg Committed by Tim Neutkens

do not use window.history if inside iframe (#3437)

* do not use window.history if inside iframe

* Move security related test cases into a its own file.

* Removes the unused renderScript function

* Add a nerv example. (#3573)

* Add a nerv example.

* Fix for indentation/style

* Fix for name

* warn user about browser history if next.js used in iframe
parent 3bbfbfad
...@@ -4,7 +4,7 @@ import { parse, format } from 'url' ...@@ -4,7 +4,7 @@ import { parse, format } from 'url'
import EventEmitter from '../EventEmitter' import EventEmitter from '../EventEmitter'
import shallowEquals from '../shallow-equals' import shallowEquals from '../shallow-equals'
import PQueue from '../p-queue' import PQueue from '../p-queue'
import { loadGetInitialProps, getURL } from '../utils' import { loadGetInitialProps, getURL, warn, execOnce } from '../utils'
import { _notifyBuildIdMismatch, _rewriteUrlForNextExport } from './' import { _notifyBuildIdMismatch, _rewriteUrlForNextExport } from './'
export default class Router { export default class Router {
...@@ -185,7 +185,9 @@ export default class Router { ...@@ -185,7 +185,9 @@ export default class Router {
} }
changeState (method, url, as, options = {}) { 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) window.history[method]({ url, as, options }, null, as)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment