Dynamic Sitemap Generation not working in production
In my nuxt.config.ts I have the following, where the URL endpoint returns an array of correctly formatted sitemap objects. I know this because when running the site locally with
npm run dev
it works great. I know this because in localhost I can see 3615 URL's pulled from the production API.
That same code is being ran full SSR on the production site at https://mcmodels.net/sitemap.xml yet it's not pulling any of the dynamic URLs.36 Replies
And as you can see the sources URL is working well, especially known since it works great in localhost. https://api.mcmodels.net/urls
An initial suspicion is that the sitemap module won't hit the "remote" api at the same domain, but I'm not sure.
what are you using to generate your sitemap?
https://api.mcmodels.net/urls This is coming from a Laravel backend on the same server.
I don't reckon the problem is there, because it generates fine and returns at that endpoint, and works at localhost.
sitemap
is not a default nuxt config value, are you using a sitemap plugin or module to generate the file and use the config setting?
https://nuxt.com/docs/api/nuxt-configYes sorry I should have clarified https://nuxtseo.com/sitemap/api/config
The official nuxt sitemap module
Followed the docs and this here: https://nuxtseo.com/sitemap/getting-started/data-sources#_2-runtime-provide-a-sources-array
I have not used that one, I've used the one from nuxt: https://nuxt.com/modules/sitemap
Click the documentation linked here 😛 https://nuxt.com/modules/sitemap#documentation
oh I guess that's the same one lol
They are the same module
I don't use the nuxt server api, much prefer doing it with laravel. But I don't see why that would make a difference since https://api.mcmodels.net/urls is clearly accessible and localhost hits it and constructs a 4000 url sitemap at the same endpoint that production is hitting.
have you tired to use an async function to get your urls?
https://nuxtseo.com/sitemap/getting-started/data-sources#_1-build-time-provide-a-urls-function
I can't get the sitemap data concurrent when I build, I need it to be updated during runtime.
I may not build the site for a few days/weeks, but products and stores change daily.
do you see anything in your server logs?
or do you see a query on your laravel log?
Laravel logs are error-free (from anything related to this) xD
I did just update the API as well to fix the last modified column being null.
again, reflects immediately when running locally
I mean on your mcmodels.net server, do you have error in your log there?
No I am ssh'ed into my server looking at laravel.log right now, there is no related errors
not laravel, your nuxt app
Also clean
Just a bunch of bots trying to hit wordpress endpoints that don't exist :heh:
I'm not sure, maybe create an issue on the sitemap gitlab page?
Yeah I will be creating an issue if this thread doesn't work out. It's such a basic thing I presumed it to be a config issue or something.
Or some rule that the sitemap won't pull from the same domain or something silly
I put in a github issue, I doubt its a bug with a module but I don't know what else to do.
Hey! Have you found a workaround?
Facing the same issue rn
I did find a workaround last night @Broken
not super happy with it but it works fine
I changed my nuxt.config.ts to have this as the source, and then inside that file:
Basically just a wrapper makes it work for some reason.
Nice! Thank you @Joshua
Trying it
So I guess you've created a file named
urls
in the __sitemap__
folder? @Joshuayes
ok nice
trying in production
the data coming back from my endpoint is already formatted for a sitemap though keep in mind
if you just return url strings you may need to do some transforming
Before I also had a wrapper but the route wasn't
__sitemap__/urls
yep me tookk cool
trying this
Yeah looks right, if urls.ts has what I sent.
Still has no urls in it 😦
https://app.radardrop.ai/airdrops-sitemap.xml
Will dig more tomorrow
Thank you for your help @Joshua
Digging more tomorrow
It’s weird, the api is working just fine
https://app.radardrop.ai/api/__sitemap__/urls
Yeah I really do think there’s an oddity with the module
ok I have this very (verbose....?) error