MinecraftStorage
MinecraftStorage
NNuxt
Created by MinecraftStorage on 1/18/2025 in #❓・help
How to cache API requests on the server side?
Hey guys, I've recently come across a problem where my server is making 4-5 calls to the API server on every request that comes to the Nuxt app. As a result, Nuxt takes a long time to respond to a user, as each API request needs to travel to another part of the world. I want to avoid this behaviour by leveraging caching, and storing API responses periodically. I've seen multiple solutions, including useFetch's getCachedData option, but they all address client side caching, while I need a solution for server-side caching. So, can you suggest a state-of-the-art solution for caching data on the server side?
11 replies
NNuxt
Created by MinecraftStorage on 10/18/2024 in #❓・help
Can you deploy Nuxt as SSR on Cloudflare pages?
I tried deploying Nuxt on Cloudflare, but the SSR seems not to work. UseFetch doesn't work on the server, but only on client. So the question is, does Cloudflare support ssr or is it only for client side apps?
15 replies
NNuxt
Created by MinecraftStorage on 6/28/2024 in #❓・help
How to assign a middleware to custom routes?
So for file-system based routing you assign middleware to individual pages or a parent page through definePageMeta utility function. But, as definePageMeta is ignored in custom routing, how do you assign a middleware in this case. I have gone through the documentation but couldn't find any clean solutions. I think you should be able to assign middleware to routes in router.options.js file like this:
{
path: "account",
name: "account",
middleware: "auth",
component: account
}
{
path: "account",
name: "account",
middleware: "auth",
component: account
}
But this doesn't work. Do you have any better solution for this?
6 replies
NNuxt
Created by MinecraftStorage on 6/27/2024 in #❓・help
How are you resolving routes while using I18n module?
Previously, I obtained route paths by passing an object with route name and parameters to NuxtLink, which worked perfectly. However, once I introduced the I18n module, all my route names have been prefixed with locale names (loginen, logines, etc.). This now makes it problematic to obtain routes as now I need to pass the current locale alongside with the route name. This makes the code unreadable and adds extra hassle to the development. Do you have any better solution for obtaining route paths?
6 replies