-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Proxy Setting via Environment Variables? #3783
Comments
I think this idea has been floated before. I'm not strictly opposed to it but the proxy functionality is getting a bit complicated so I think we should revisit this after simplifying the “advanced” configuration case: #3366. |
Alright, I see. Cool. |
@vegtelenseg the way I worked around it is that I've set my production proxy in
Finally, I have a script called |
+1 for this. My usecase is 2 distinct commands like: "start-staging": "PROXY=https://staging.domain.com", |
@gaearon I see #3366 is already closed, any updates on this? |
For anyone else searching for an answer, it turns out the |
I created this pull request #5720. |
This is no longer necessary now that you can configure your own proxy and use any environment variable you wish. |
Do you show us sample code? |
Also here, do you show us sample code how you define and use dev/prod base urls? |
I suggest you file a question on Stack Overflow, you can link it here! |
This doesn't seem to work with current version of CRA. |
I was able to get this to work with a custom const proxy = require('http-proxy-middleware')
const pkg = require('../package.json')
const target = process.env.PROXY || pkg.proxy
module.exports = app =>
target &&
app.use((req, res, next) =>
req.accepts('text/html') ? next() : proxy({ target })(req, res, next)
) |
I have a question.
Instead of providing proxy information via the
package.json
, is it possible to achieve exactly the same thing by providing this information directly into environment variables?The text was updated successfully, but these errors were encountered: