-
Notifications
You must be signed in to change notification settings - Fork 544
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
Built-in proxy support #113
Comments
@pi0, would you be able to give any ETA on this one? 🙏 Would be super useful to have it working in Nuxt 3. |
Will work on it ASAP. In the meantime you can use https://www.npmjs.com/package/nuxt-proxy for Nuxt 3 apps only keep in mind some options are probably going to be simplified compating to http-proxy so avoid using options when possible to reduce breaking change chances. Alternatively you can define a nitro route handler that uses fetch to upstream for proxy effect. This gives full control over headers. |
can't use nuxt3@latest because proxy issues, non module working rn. is nitro proxy ready yet? |
devProxy doesn't seem to be supporting relative URL in fetch, is this by design? (nitro 0.6.1) I.e. // config:
export default defineNuxtConfig({
nitro: {
devProxy: {
'/api/': {
target: process.env.API_TARGET,
changeOrigin: true
}
}
}
})
// ======================
// later, on server side:
// ======================
const r = await (await fetch('/api/test')).json();
// => 500 Invalid URL |
@makkarpov Yes. You need to pass full URLs because dev proxy is outside of worker and needs to make an actual request. |
Any indication when it will be fully implemented? |
But this breaks code unification between client and server. In browser, when I make a Otherwise, you either need to add another layer ontop of fetch, or you will end up with a lot of boilerplate for converting URLs to absolute. |
It's also desirable (but far less annoying) to proxy WebSocket requests for same reason. This time things are even more complicated: you have to invent ad-hoc logic on client. This means, you need to put all your backend paths into a |
Web socket layer and runtime proxy support (with direct fetch ability) are on the way :) |
Available yet? |
Will this be available soon? I can't send auth requests to my backend because of it. Before this is integrated, I can't use Nuxt 3. |
Some ETA would me much appreciated. Our team is also waiting for this. |
Any news on it? |
bumping this every day certainly will not make it faster, plus it annoys everyone who subscribed to this issue for actual updates, so please, just don't. |
While you wait, you can follow pi0's earlier advice:
|
Commenting here in case this info is useful to anyone. For some reason, I couldn't get vite proxy to match any of the regex I was writing. After investigation, it seems like all the routes tested by vite are prefixed with For context, the configured root route on my project is a catch-all, ( |
Runtime proxy support is finally possible via #926 (in nitropack-edge and upcoming 2.1.0 release). Cheers! |
Adding as a feature to route rules.
The text was updated successfully, but these errors were encountered: