@nuxtjs/sitemap won't generate the dynamic URLs in production
Hi, i'm using nuxtjs/sitemap module and i set up under server/api/sitemap/urls.ts the logic to retrieve all my dynamic urls (it's an ecommerce). When running npm run dev i see everything ok, in the sitemap there are over 600 link product urls. But when pushing and hitting the sitemap in production I only see the static pages i created. Can somebody help me? The app is on Heroku
Solution:Jump to solution
Yea I was used to it on Netlify but on Heroku it didn't seem like it. Anyway I managed to make it work editing the middleware like this:
```js
export default defineEventHandler((event) => {
if (process.env.NODE_ENV === "production") {
const req = event.node.req;...
15 Replies
Try clearing the app’s cache on heroku, then redeploy it
done, no success. I leave here some more details:
The last url looks out of place. I’m something might be wrong with the config, but the docs also uses the same approach
well, i indeed followed the official docs. Yeah and i don't know why the url of the api gets printed in the production sitemap. I don't really get what's wrong here
I haven’t actually used
@nuxtjs/sitemap
before so I’d have try it out on my end to be able to further assist. For what I’ve used, clearing cache and redeploying usually solves the problemTurns out that the server middleware i created for SSl force is causing trouble to the sitemap:
disabling it the sitemap is generated correctly, i thought these exclude parameters were enough!
Oh okay. What does the middleware do though? Asking out of curiosity
it enforces https. Maybe I can achieve it differently?
For the server api?
nope, for the normal navigation. I did it because it didn't automatically redirect http to https when hitting the http
I see. Isn’t this usually handled by the deployment platform? Netlify and Digital Ocean for instance automatically redirect to https if you enter http
Solution
Yea I was used to it on Netlify but on Heroku it didn't seem like it. Anyway I managed to make it work editing the middleware like this:
That’s nice! 👍