Going from documentation, it seems to be supported: Nuxt on Vercel
Also from the Nitro documentation, proxy is a core route rule: Server Routes - Nitro
Is this supposed to work with Vercel?
I would use a vercel.json with rewrites, but it doesn’t seem like they support endpoints based on environment variables?
Sadly, adding the same nitro config to my Nuxt app doesn’t help, and Nuxt also complains:
WARN Using nitro.config.ts is not supported together with Nuxt. Use options.nitro instead. You can read more in https://nuxt.com/docs/api/nuxt-config#nitro.
Is there any way to see what rewrites are set up for a given project in Vercel based on app configuration?
I’m wondering if Vercel is picking up nuxt.config.ts first, and ignoring the nitro.config.ts…
Tried that already, and it didn’t help unfortunately. Same results, but at least Nuxt doesn’t complain about it, and tackles it properly.
Do you have any insight into how the underlying Vercel implementation actually works? What property is the “official” one for Nuxt projects?
You should be able to use the Nuxt.jsframework preset to handle the build and development settings for most Nuxt projects. I’m not able to replicate the issue you’re seeing.
Here’s my latest attempt based on the basic Nuxt starter app. Only thing I changed was the nuxt.config.ts file to include nitro.routeRules.
Do you have a public repo or minimal reproducible example that you can share here? Real apps are always more complex than the quick start templates from any framework. There could be some other configuration in the app that’s preventing the proxy rewrite.
After much debugging, I figured out that the “problem” was that in our project, we had a folder called “api”.
This just contains our actual API client to interface with our backend, and is not part of the routable pages in the Nuxt app.
Seems like this conflicts with the rewrite somehow, because once renaming it to something else, the rewrite works!
Maybe you should consider adding a “gotcha” to the rewrite docs that any route defined cannot have a folder with the same name, or maybe this is a bug?