-
-
Notifications
You must be signed in to change notification settings - Fork 588
Preset vercel: query params are ignored by cache #1880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This happens in node environment also, but only in production I believe |
I can confirm this issue. And also can provide a reproduction if needed. |
Also running into this. |
I've run into this in a Vercel preview environment when trying to migrate my API endpoints from manual configuration via export default defineNuxtConfig({
routeRules: {
'/api/**': {
swr: 60 * 60, // 1h
},
},
}); A bunch of API endpoints started throwing errors because they were missing a required query param. I added a log line to one of the endpoints: console.log('query:', JSON.stringify(getQuery(event))); This shows up in the Vercel runtime logs for each request:
A similar request against the dev server results in:
|
As an additional note to the previous comment, although my app makes several calls to the above endpoint for each view (something like paginating through a large result set with requests like I would guess that setting |
We just got stung by this (on Vercel with While #2375 seems promising, we're probably going to migrate the query param to a route param. |
I am having the same issue but with my case, the problem is that I cannot migrate to a route param. In my setup, we have a Nuxt 3 app deployed to Vercel and Storyblok as a CMS. Storyblok adds Does anyone have any other idea on how this could be acomplished? |
You need to use both E.g. for my paginated blog index page "/blog": {
isr: {
allowQuery: ["page"],
expiration: 3600,
passQuery: true,
},
}, |
Do you use I managed to make it work by instead of watching for query param to get information from the |
We use the You might want to open a dedicated issue for the 500 error you're seeing with some details? Would you mind sharing the respective route rule? |
we encountered the similar behavior: with vercel-edge it works properly (but slower than serverless functions, as if the data wasn't located in Europe's cdn's where I'm located - not really important right now). with vercel serverless functions enabled, the route doesn't serve the dynamic data depended on query params (filtering and stuff like that) - like the nuxt config was ignored for I discovered that route.query is not accessible or empty - as If it was cached using a key made of only route path, without taking params into account. when |
I tried implementing an ISR cache busting middleware and adding a query param to a wildcard route (like below) triggered a 404 as well on all pages. Did you try it on a dedicated/know URL? "/**": {
isr: {
allowQuery: ["forceRefresh"],
expiration: 3600,
passQuery: true,
},
}, |
I created a little nitro plugin to ensure what request comes in the serverless function: export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook("request", (event) => {
const queryParams = getQuery(event);
console.log(
"on request ----------------------",
queryParams,
event.path,
event.headers,
event.context,
event.node.req,
);
});
}); and found that the queryParams are not present inside the function - despite of being discovered by vercel gateway at the beginning (blue rectangle): |
Environment
nitro: 2.7.0
node: v18.18.0
nuxt: 3.8.0
Reproduction
not available
Describe the bug
I use query params to figure out what page in a pagination the server should render, e.g. /?page=1
When configuring cache like this
vercel's cache seems to ignore the query param "page". When loading "/?page=2" I receive the cached version for "/".
This doesn't seem the be an issue with Vercel, because other pages (not nuxt/nitro) don't suffer from this issue.
So my assumption is this is an issue with nitro's vercel preset.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: