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

Dynamic URLs not getting generated on the Nuxt 3.3.1 SSR #32

Closed
NeroN7F opened this issue Apr 18, 2023 · 3 comments
Closed

Dynamic URLs not getting generated on the Nuxt 3.3.1 SSR #32

NeroN7F opened this issue Apr 18, 2023 · 3 comments

Comments

@NeroN7F
Copy link

NeroN7F commented Apr 18, 2023

Describe the bug

Having the issue with the generation of dynamic URLs, using Handling dynamic URLs method.

Initializing the sitemap module in the nuxt.config.ts

sitemap: { siteUrl: 'https://website.com, autoLastmod: false, },

In the server/api/_sitemap-urls.ts

export default cachedEventHandler(async e => {

    const products = await $fetch('https://ap, {
        method: 'GET'
    })

    return products.map((p: any) => {
        loc: p.get_absolute_url
    })
}, {
    name: 'sitemap-dynamic-urls',
    maxAge: 60 * 10 // cache URLs for 10 minutes
})

API returns the urls like:

{
"get_absolute_url": "url1"
}
{
"get_absolute_url": "url2"
}
{
"get_absolute_url": "url3"
}

However, after the project building the sitemap.xml generated only existing routes that are located in the pages folder, without fetching routes from the API and including them in the sitemap

It was also noted that the original example of Handling dynamic URLs throws an error

Error: Transform failed with 1 error:                                                                                                                                                                                                                                                       nitro 22:35:42
F:\project\server\api\_sitemap-urls.ts:12:75: ERROR: Expected ";" but found ":"

Reproduction

Install Nuxt 3.3.1 alongside nuxt-simple-sitemap 2.4.11, create the server api to fetch dynamic urls

System / Nuxt Info

No response

@austriker27
Copy link

I also got this error with the example in the README:

Error: Transform failed with 1 error: > nitro 22:35:42
F:\project\server\api_sitemap-urls.ts:12:75: ERROR: Expected ";" but found ":"

  • Nuxt version: 3.4.0,

@harlan-zw
Copy link
Collaborator

Thanks! Have pushed up a syntax error fix for the docs.

Would you be able to provide a Stackblitz reproduction for the dynamic URLs not appearing? You can use this as a starter: https://stackblitz.com/edit/nuxt-starter-dyraxc?file=server/api/_sitemap-urls.ts

@NeroN7F
Copy link
Author

NeroN7F commented Apr 21, 2023

It's seems that the problem was on the server side, managed to make it work. Thank you

@NeroN7F NeroN7F closed this as completed Apr 21, 2023
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

3 participants