N
Nuxt2y ago
Zampa

Different URLs for client XHR request and SSR XHR requests?

Does anyone know if there is a way to use one URL for all SSR-initiated API XHR requests, and another URL for all browser (client-side) API XHR requests? I'm noticing that if I have API calls in a server route, it's adding 5x delay to the raw XHR request that happens in the browser. Example: Call the API endpoint in the browser: 20-30ms Nuxt SSR calls the API endpoint from a Nuxt server route: 150-200ms So presumably there is some way to do this using middleware? A custom wrapper for all API requests (/api/*) that would either : 1) use a fully qualified API endpoint URL (https://api.mysite.com/api/...) for all client-side API calls 2) use a relative API endpoint URL ('/api/...) that references the Nuxt server route /api/[...].ts for all server-initiated API calls (any time a page is server rendered, and that page requires data from an external API
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server