Tackleberry
API routes with route params not having types
I noticed my API routes only have typings if they do not contain a route param. Is this expected behavior? Is there a way to fix / improve it in the project? The docs don't say anything about it.
Example:
5 replies
Caching images generated by NuxtImage
I am experiencing a high server load since I started using NuxtImage, because images get generated from scratch all the time. Is there no way of caching images generated by nuxt image for a longer duration? It seems they are cached for 60 seconds only.
I tried using something like
but this breaks images completely.
5 replies
SWR vs maxStaleAge
How do swr and maxStaleAge in a defineCachedEventHandler play together? The docs say:
swr: boolean
Enable stale-while-revalidate behavior to serve a stale cached response while asynchronously revalidating it. Defaults to true.
staleMaxAge: number
Maximum age that a stale cache is valid, in seconds. If set to -1 a stale value will still be sent to the client while the cache updates in the background. Defaults to 0 (disabled).
So swr
defaults to true
, and a stale cached response should be served. However, staleMaxAge
defaults to 0
, which means a stale cache is always invalid and will not be served to the client? This doesn't make any sense, does anyone have insight?1 replies
How to stop Nuxt from preloading in dev mode?
Dev mode preloads and applies all kinds of stylesheet that I don't want to be preloaded. I'm trying to get rid of that, but can't find a way.
I relented to manipulating the head directly, but can't find a way to do that either!
- useHead seems to have no way of removing elements.
- I tried using the
'app:rendered'
hook, but the renderResult.html only contains the body, and renderStyles() is only a function without any method to change the result.
Is there no way to prevent nuxt from falsely including a bunch of stuff on the page that I don't want? 😦1 replies
e2e testing api routes: "setup" is not exported by "node_modules/unenv/runtime/mock/proxy.mjs"
I'm trying to test my nuxt api routes to make sure they work correctly. I've followed the setup guide from https://nuxt.com/docs/getting-started/testing#end-to-end-testing.
But when I try to run the example test from https://nuxt.com/docs/getting-started/testing#setup-1 with vitest, I get the following error:
RollupError: server/api/jobs.nuxt.test.ts (2:9): "setup" is not exported by "node_modules/unenv/runtime/mock/proxy.mjs", imported by "server/api/some-route.nuxt.test.ts"
Am I missing something obvious here?
Additional info: I used the installation command from the setup section, minus playwright-core since I want to use vitest as test runner: npm i --save-dev @nuxt/test-utils vitest @vue/test-utils happy-dom
.
Full error message:
2 replies