question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simplify our "advanced" proxy

See original GitHub issue

I think we made a mistake when we added advanced proxy configuration in 1.x.

It’s poor DX imo, and has caused numerous issues (I’m too lazy to search for them 😝). I mean look at this monstrosity. Yuck!

Note: this is not an attack against the contributor of this change. We are very grateful for the contribution and it has served us well. 😄

I propose we support the simplest of configurations:

  1. Our default, simple behavior which works for many cases:
      "proxy": "http://localhost:4000",
    
  2. An advanced case, which uses globs and proxies in 100% of cases (no heuristic):
      "proxy": [
        { "match": ["api/**/*", "!api/ws/*"], "target": "http://localhost:4000" },
        { "match": "api/ws/*", "target": "ws://localhost:4000" },
        { "match": "api2/**/*", "target": "http://localhost:4001" }
      ]
    
    or
      "proxy": [
        [["api/**/*", "!api/ws/*"], "http://localhost:4000"],
        ["api/ws/*", "ws://localhost:4000"],
        ["api2/**/*", "http://localhost:4001"]
      ]
    

In the “advanced” case, we don’t need to set ssl – check for https:// over http://. We don’t need to set ws, check for ws://; etc. Other features (e.g. url rewrites) should never happen at the client layer because this doesn’t translate to production (it’s leaky domain logic).

Thoughts?

We can add some code to auto-migrate old usage and remove it in v3.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:24 (9 by maintainers)

github_iconTop GitHub Comments

20reactions
snardonecommented, Jan 9, 2018

@Timer, the new approach looks good but I have one request based on issues we’ve run into with our team. It would be helpful if the target value could be configurable outside of package.json.

In our environment, developers can test against the back-end running locally, or against a VM, or against a cloud server. So they modify their package.json accordingly, which gets accidentally checked it, which leads to conflicts, etc.

One solution might be to support environment variables in the target, for example:

"proxy": [
    { "match": ["api/**/*", "!api/ws/*"], "target": "http://${PROXY_HOST}" },
    { "match": "api/ws/*", "target": "ws://${PROXY_HOST}" },
    { "match": "api2/**/*", "target": "http://${PROXY2_HOST}" }
  ]

Thanks!

13reactions
maxhallinancommented, Jan 10, 2018

@gaearon asked me to continue #3204 on this issue. To summarize:

  • Proxy configuration is part of package.json.
  • package.json is usually (maybe always) under source control.
  • The location of a proxy target can vary with the environment.
  • Because the proxy configuration is under source control, the location of the proxy target must be aligned across environments.
  • Thus, it would be nice to move proxy configuration to the environment.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Solve Proxy Error Codes - The Ultimate Guide!
The easiest way to solve these proxy error codes is by using a proxy manager. A proxy manager is often a free and...
Read more >
Verify the Proxy Settings are Correct on a Computer
Click the Advanced button; Click the Proxies tab; Select the box Auto Proxy Discovery; Click OK; Click Apply. These settings will help ensure...
Read more >
Simplify Proxy Voting from Start to Finish for Corporate Issuer
Simplify Proxy Voting from Start to Finish. Leverage a unified platform and automated workflows for confidence in every proxy vote execution.
Read more >
Proxy for ActiveGate | Dynatrace Docs
Advanced proxy configuration scenarios for ActiveGate · ActiveGate proxy for Kubernetes, CloudFoundry, and private Synthetic Monitoring · Different proxies for ...
Read more >
IBM Sterling Secure Proxy - Overview
Includes proxy support and functions to improve security of edge-based file exchanges. Dynamic routing. Provides advanced routing to simplify infrastructure ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found