vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.04k stars 27k forks source link

Cannot read property 'href' of undefined #4731

Closed chilijung closed 6 years ago

chilijung commented 6 years ago

Bug report

Describe the bug

Don't know what happened inside next.js, prompting error I don't understand. Hope someone could point me a direction that I might know where to find the problem. Thanks

I'm getting this:

TypeError: Cannot read property 'href' of undefined
    at getURL (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/next/dist/lib/utils.js:155:30)
    at new Router (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/next/dist/lib/router/router.js:101:29)
    at _callee3$ (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/next/dist/server/render.js:235:22)
    at tryCatch (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/@babel/runtime/helpers/asyncToGenerator.js:12:30)
    at _next (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:9)
    at <anonymous>
TypeError: Cannot read property 'href' of undefined
    at getURL (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/next/dist/lib/utils.js:155:30)
    at new Router (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/next/dist/lib/router/router.js:101:29)
    at _callee3$ (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/next/dist/server/render.js:235:22)
    at tryCatch (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/@babel/runtime/helpers/asyncToGenerator.js:12:30)
    at _next (/Users/lijung/Documents/canner/canner-firebase-cms/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:9)
    at <anonymous>

To Reproduce

You can try by clone this branch and start, npm run dev https://github.com/Canner/canner-firebase-cms/tree/nextjs

go to path /dashboard

System information

chilijung commented 6 years ago

I resolve this issue myself, I accidentally assign window variable to a blank {}, which will make things break when server-side rendering.