jakeburden / next-absolute-url

Get the absolute URL of your Next.js app (optionally set a localhost dev URL)
300 stars 30 forks source link

Cannot read property 'indexOf' of undefined #6

Closed halkeye closed 5 years ago

halkeye commented 5 years ago
Cannot read property 'indexOf' of undefined
TypeError: Cannot read property 'indexOf' of undefined
    at absoluteUrl (/node_modules/next-absolute-url/index.js:4:12)

I tried both the 2 param and the 1 param version

I think that line should be changed to:

  var host = req ? (req.headers['x-forwarded-host'] || req.headers['host']) : window.location.host;

so it grabs host if x-forwarded-host is not set.