I have a nuxt 3 app deployed on netlify (https://splendid-salamander-811513.netlify.app). For one of the pages (/hasznaltauto), I have a middleware that adds query params if they don’t exist and navigates to same page with these query params - this is in order to always have default query params in place.
When I go to url “https://splendid-salamander-811513.netlify.app/hasznaltauto”, (without any query params) on netlify, it gets into infinite redirect loop, however in local there is no such issue. Also, it works perfectly for internal navigation (e.g. one of the nuxt links in header points to /hasznaltauto without any query params) both on netlify and in local.
Appreciate any guidance in terms of what can be causing this / how to rectify.
Instead of adding detault params to the URL, why not process the data with the default values of the params? For example, if you’re making an API call by reading the query params, why not just make the API call with the default values and not modify the URL at all? Seems like a much simpler way to handle this situation.
But about the issue, not sure if Netlify would be able to help you with this. Nuxt generates and maintains its integration for Netlify and whatever happens within the serverless functions is entirely your and Nuxt’s code. Netlify is simply running it. As far as I can see, there’s no reason to send a redirect loop, because based on your explanation, once there are request parameters, there should not be a request.
One interesting point of information that we discovered was that, Nuxt has added this redirect for your site:
/hasznaltauto/* /.netlify/builders/server 200
Notice how that’s pointing to /.netlify/builders
- that’s Netlify’s On Demand Builders and they don’t have access to request params. This could be causing the issue. But why Nuxt is generating that redirect? That we don’t know. Usually, Nuxt generates a redirect to /.netlify/functions/server
- maybe you’ve made it an ISR page or something?