Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

cannot read cacheTime of undefined #27

Open
markus-gx opened this issue Jan 13, 2023 · 5 comments
Open

cannot read cacheTime of undefined #27

markus-gx opened this issue Jan 13, 2023 · 5 comments

Comments

@markus-gx
Copy link

Error:

[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'cacheTime')                                                                                                                                                                                                                                                                    10:34:31
  at createRoutesCache (./node_modules/@funken-studio/sitemap-nuxt-3/dist/runtime/cache.mjs:8:21)  
  at ./.nuxt/dev/index.mjs:483:40  
  at Object.handler (./node_modules/h3/dist/index.mjs:845:12)  
  at Object.handler (./node_modules/h3/dist/index.mjs:681:31)  
  at processTicksAndRejections (node:internal/process/task_queues:96:5)                                                                                                                                                                                                                                                                                               10:34:28
  at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:745:7)

Environment:
Nuxt 3.0.0

Sitemap Configuration:

sitemap: {
    hostname: process.env.DOMAIN,
    cacheTime: 1,
    trailingSlash: true,
    exclude: ['/_internal', '/_internal/styleguide'],
    routes: dynamicRoutes,
    defaults: {
      changefreq: 'daily',
      priority: 1,
      lastmod: new Date().toISOString(),
    },
  },
@Leapfrognz
Copy link

Also experiencing this issue.

@Kerimhan05
Copy link

Kerimhan05 commented May 23, 2023

faced with this problem, haven't you solved it?

Environment - Nuxt 3.3.2

Configuration:
image

@markus-gx
Copy link
Author

faced with this problem, haven't you solved it?

Environment - Nuxt 3.3.2

Configuration: image

I am not using this module anymore. What I've done is to create a file called sitemap.xml.get.ts in the folder server/routes
Where I define the following:

//servers/routes/sitemap.xml.get.ts
export default defineCachedEventHandler(async (event) => {
  const runtimeConfig = useRuntimeConfig()
  const routes = await retrieveRoutes() //retrieve your routes either from an api or elsewhere
  const sitemap = [
    '<?xml version="1.0" encoding="UTF-8"?>',
    '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
    ...routes.map((route) =>
      [
        '<url>',
        `  <loc>${runtimeConfig.public.domain}${route.path}</loc>`,
        `  <lastmod>${route.lastmod}</lastmod>`,
        '</url>',
      ].join('')
    ),
    '</urlset>',
  ].join('')
  setHeader(event, 'content-type', 'application/xml')
  return sitemap
})

@Kerimhan05
Copy link

Kerimhan05 commented May 23, 2023

столкнулся с этой проблемой, вы не решили ее?
Окружающая среда — Nuxt 3.3.2
Конфигурация:изображение

Я больше не использую этот модуль. Что я сделал, так это создал файл с именем sitemap.xml.get.tsв папке server/routes , где я определяю следующее:

//servers/routes/sitemap.xml.get.ts
export default defineCachedEventHandler(async (event) => {
  const runtimeConfig = useRuntimeConfig()
  const routes = await retrieveRoutes() //retrieve your routes either from an api or elsewhere
  const sitemap = [
    '<?xml version="1.0" encoding="UTF-8"?>',
    '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
    ...routes.map((route) =>
      [
        '<url>',
        `  <loc>${runtimeConfig.public.domain}${route.path}</loc>`,
        `  <lastmod>${route.lastmod}</lastmod>`,
        '</url>',
      ].join('')
    ),
    '</urlset>',
  ].join('')
  setHeader(event, 'content-type', 'application/xml')
  return sitemap
})

@Kerimhan05
Copy link

it turns out I manually create a sitemap?
Are there other packages that support nuxt 3?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants