Cannot read property 'replaceState' of undefined
On first load, my now.js hosted app works as expected but as soon I reloaded the page I was met with 503. The only addition in this version of my app is a package for recording audio in the browser RecordRTC. The error message (bellow) is a bit arcane and any advice for how to to approach it would be greatly appreciated!
TypeError: Cannot read property 'replaceState' of undefined at Router.changeState (/home/nowuser/src/node_modules/next/dist/lib/router/router.js:383:23) at new Router (/home/nowuser/src/node_modules/next/dist/lib/router/router.js:99:12) at renderPage (/home/nowuser/src/node_modules/next/dist/server/render.js:150:25) at Function.getInitialProps (/home/nowuser/src/node_modules/next/dist/server/document.js:83:25) at _callee$ (/home/nowuser/src/node_modules/next/dist/lib/utils.js:36:30) at tryCatch (/home/nowuser/src/node_modules/regenerator-runtime/runtime.js:65:40) at Generator.invoke [as _invoke] (/home/nowuser/src/node_modules/regenerator-runtime/runtime.js:303:22) at Generator.prototype.(anonymous function) [as next] (/home/nowuser/src/node_modules/regenerator-runtime/runtime.js:117:21) at step (/home/nowuser/src/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30) at /home/nowuser/src/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
What's the browser and OS. Seems like it's doesn't have HTML5 History API
It's a requirement for Next.js
After doing some more poking around that's what I thought might be the issue except the error is occurring on chrome 58.0.3029.110 (64-bit) on both Arch and Windows 10 :/ which both have the History API.
After digging around both sources it looks like RecordRTC was trying to mock a new window during server side rendering and that mock was missing history.
Solved the issue by conditionally requiring the package in the OnComponentDidMount of the component that needed it.