Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The @nuxtjs/sitemap module requires a site.url to be set when using nitro plugin #288

Closed
P4sca1 opened this issue Aug 7, 2024 · 1 comment

Comments

@P4sca1
Copy link

P4sca1 commented Aug 7, 2024

Describe the bug

I followed the guide for a dynamic site config from here: https://nuxtseo.com/site-config/guides/runtime-site-config

During nuxt build I get the following error:

✔ Server built in 8592ms                                                                                                            6:12:17 PM
ℹ Initializing prerenderer                                                                                                    nitro 6:12:18 PM

 ERROR  The @nuxtjs/sitemap module requires a site.url to be set:                                                   nuxt-site-config 6:12:18 PM
  - Required to generate absolute canonical URLs for your sitemap.

You can fix this by adding a site.url to your nuxt.config or a NUXT_PUBLIC_SITE_URL to your .env. Learn more at https://nuxtseo.com/site-config/getting-started/how-it-works

ℹ Prerendering 1 routes 

server/plugins/site-config.ts

export default defineNitroPlugin(async (nitroApp) => {
	nitroApp.hooks.hook('site-config:init', ({ event, siteConfig }) => {
		const config = useRuntimeConfig(event)

		siteConfig.push({
			name: 'my name',
			description:
				'my description',
			defaultLocale: 'de',
			url: config.public.url,
			isIndexable: config.public.stage === 'production',
		})
	})
})

Reproduction

No response

System / Nuxt Info

------------------------------
- Operating System: Darwin
- Node Version:     v20.15.1
- Nuxt Version:     3.12.3
- CLI Version:      3.12.0
- Nitro Version:    2.9.7
- Package Manager:  [email protected]
- Builder:          -
- User Config:      ssr, telemetry, compatibilityDate, future, vite, typescript, css, app, sourcemap, runtimeConfig, modules, devtools, content, fonts, seo, schemaOrg, robots, sitemap, ogImage, colorMode, security, routeRules
- Runtime Modules:  @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @pinia/[email protected], @vueuse/[email protected], [email protected], [email protected], @formkit/auto-animate/[email protected]
- Build Modules:    -
------------------------------
@harlan-zw
Copy link
Owner

Hi @P4sca1, seems like a bug in it not supporting the runtime config when prerendering, I'll try to have it fixed soon, please ignore for now OR set static placement values in your nuxt.config to hide.

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

No branches or pull requests

2 participants