nuxt-community / proxy-module

The one-liner node.js http-proxy middleware solution for Nuxt 2 using http-proxy-middleware
MIT License
408 stars 25 forks source link

dynamic proxy target #70

Open iteamaster89 opened 4 years ago

iteamaster89 commented 4 years ago
iteamaster89 commented 4 years ago

Hi. Could anybody help to know how to toggle between proxies from the app if it's possible? For example, to have checkbox on page which toggles proxies from prod to dev mode.

atinux commented 3 years ago

I don't think this is possible since it is set at runtime, what would be the use-case @iteamaster89 ?

davydnorris commented 3 years ago

I was just looking for a similar thing!

I am building an app to analyse another system, and need to use the other system's REST API to get configuration details. I want to be able to enter the remote system's URL and authentication details at run time and then use axios to pull the data, and I'm getting CORS errors, as expected.

It looks like axios/proxy won't let me do this? Everything is set at dev time?

mindfullsilence commented 3 years ago

Also looking to do this. I have a multi-tenant application built in laravel which I would like to proxy the api for (esp. using nuxt/auth-next package).

Each tenant has their own api subdomain (someuser.example.com/api), so the login form has 3 fields: domain, email, password. The target of the proxy needs to reflect what the user inputs in the domain field (obviously after sanitizing/validating).

greabock commented 3 years ago

@mindfullsilence did you found any solution?

kairyou commented 2 years ago

The http-proxy-middleware gives the option of re-target option.target for specific requests. option.router