-
Notifications
You must be signed in to change notification settings - Fork 513
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
feat: support runtime proxy using route rules #926
Conversation
Codecov Report
@@ Coverage Diff @@
## main #926 +/- ##
==========================================
+ Coverage 67.40% 67.73% +0.32%
==========================================
Files 59 59
Lines 5968 5979 +11
Branches 668 678 +10
==========================================
+ Hits 4023 4050 +27
+ Misses 1936 1920 -16
Partials 9 9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@yancyhuang It is partially with |
Will path rewrite support come? Like devProxy.
or i'm missing something about this topic? |
@antlionguard Something like this has same effect in route rules: |
Hi! π Is there an issue that tracks this? |
@pi0 , Thanks for this. Would it be possible to acheive something like this using variables? export default defineNuxtConfig({
routeRules: {
'/api': { proxy: NUXT_API_PROXY },
}
}) |
@blowsie For dynamic target, you should make a custom route handler and use |
@pi0, any way I can use the same for static build? (by |
@imzedi With a static build, you platform or reverse proxy has to handle that as no "nuxt/nitro" server is running |
BTW depends on the static deployment platform. One of proxy via route rule advantages is that we can technically generate platform (or reverse proxy) config. |
@pi0 e.g. for netlify you mean? |
Yes like this we can use for static presets. |
Hello, thanks for maintaining such an awesome library!
Thanks! |
π Linked issue
#113
β Type of change
π Description
Support runtime proxy using route rules and
h3.proxyRequest
(universally works with fetch)Local support is pending unjs/h3#321
For more advance usages, users can always create a route like
routes/proxy/[...path].ts
and directly usereturn proxyRequest(path, { target })
and have full control over path handling, etc.π Checklist