N
Nuxt3mo ago
dee_gg

Bypass Nuxt and serve other server's response (proxy?) for a sitemap.xml?

Hi! I'm building a website with Craft CMS as a headless CMS and Nuxt in front of it. Craft has a great SEO plugin called SEOMatic and it does everything we need it to do. I've been able to feed the metadata by fetching it through our graphql api, no problem there, but the sitemap.xml is generated already and fully properly configured so I'd like to serve it directly instead of consuming it in Nuxt and then re-serving it barely changed. Is this what routeRules with the proxy param should be helping me with? I'm confused because I can't get it to work, but maybe a proxy isn't the best solution either. I'd love to hear from anyone who's configured Nuxt to just pass the request on to another server (proxy?) https://nitro.unjs.io/guide/routing#route-rules Here's a simple version of my non working config so far:
export default defineNuxtConfig({
nitro: {
preset: 'cloudflare-pages',
},

routeRules: {
'*.xml': {proxy: 'https://admin.geloso.com'}
},
});
export default defineNuxtConfig({
nitro: {
preset: 'cloudflare-pages',
},

routeRules: {
'*.xml': {proxy: 'https://admin.geloso.com'}
},
});
3 Replies
dee_gg
dee_ggOP3mo ago
Update: Trying through a server api interception works (ex.: /servers/api/[...].js), but routes/[...].js but I need it to not have /api in the url and thus tried /servers/routes/[...].js and it doesn't catch
Cue
Cue3mo ago
I presume you’re hosting this on a VPS somewhere? IIRC I left proxying through Nuxt just for the API, everything else I proxied directly through nginx I.e. sitemaps, as it makes no sense to send a request from web server to node, through nitro, and proxy back to the web server.
harlan
harlan3mo ago
you can just make a sitemap index file and point to to your other path proxy should have been the solution afaik though i think the issue is your matching pattern *.xml, i'm not sure if this is supported
Want results from more Discord servers?
Add your server