#error Cannot read properties of undefined (reading 'pathname')

1 messages · Page 1 of 1 (latest)

solemn summit
#

This is what is see

 error   Cannot read properties of undefined (reading 'pathname')
    at /Users/xxx/Code/lrastro/src/components/BaseHead.astro:3:0
    at renderToString (/node_modules/astro/dist/runtime/server/index.js:342:27)
    at Module.renderComponent (/node_modules/astro/dist/runtime/server/index.js:125:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) (x2)

And the file BaseHead.astro looks like this

---
import FontPreload from './FontPreload.astro'
const {
  title,
  description = '',
  metaDesc,
  robotsMeta = 'index, follow'
} = Astro.props
let formattedTitle = `${title}`
let formattedDescription = metaDesc || description
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
---
#

"astro": "1.0.0-beta.10"

#

node v16.13.0

compact bear
#

Astro.url was introduced at v1.0.0-rc so either update your Astro version or create your own URL object with Astro.request.url

const url = new URL(Astro.request.url);