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.

CORS hassle free proxy

See original GitHub issue

If I’m missing something and/or wrong about this, please correct me, thanks!

I find the implementation using https://github.com/chimurai/http-proxy-middleware is convenient, except that it’s not always so simple when facing Access-Control header restrictions, which often requires the API/Data/Backend server to configure CORS.

One sure way I can think of is to use an HTTP client library such as https://github.com/mzabriskie/axios or https://github.com/request/request to make the request through server side (which to my understanding isn’t restricted by the cross-origin settings anymore) and pipe the retrieved response to the client, like req.pipe(request({...API_OPTIONS...})).pipe(res) for the simplest example inside the API tunneling/proxy middleware.

Again, maybe I’m missing something very obvious and dead simple to achieve the same through http-proxy-middleware, in which case please point out.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
asvaecommented, Jan 27, 2017

Not sure if that’s related, but here’s my dev-server config:

{
  devServer: {
    historyApiFallback: true,
    noInfo: true,
    proxy: {
      '*': {
        target: 'http://my-project.local',
        changeOrigin: true,
        secure: false,
        cookieDomainRewrite: '',
        onProxyReq: function (request, req, res) {
          request.setHeader('origin', 'http://my-project.local')
        }
      },
    }
  },
}

Works with CORS and cookie authentication.

3reactions
LinusBorgcommented, Nov 1, 2017

Since this issu eis quite old, and we will switch to webpack-dev-server in the coming days, I wil close this. If this still needs further discussion, please open a new issue with a reference to this one and we will see how to resolve this in the new envorinment with webpack-dev-server, if necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

10 Free to Use CORS Proxies - Nordic APIs
Free CORS Proxy Servers · 1. CORS Anywhere · 2. HTMLDriven · 3. Taskcluster · 4. thingproxy · 5. Whatever Origin · 6....
Read more >
Free / Reliable CORS proxy service | by softmarshmallow | Grida
As a solution of this, we've opened up our cors proxy server (used by our product: assistant) and made available for everyone.
Read more >
Cors proxies - Discover gists · GitHub
Cors proxies. ... violating is a hefty fine!), but anyway you shouldn't be sending highly confidential data/credentials through a free proxy you don't...
Read more >
What are CORS proxies, and when are they safe? - HTTP Toolkit
CORS proxies can leak private state between independent origins · You make a request to a.com in your web page, through your CORS...
Read more >
Free CORS proxies! - Siderite's Blog
Good Samaritans have created CORS proxies to help with that! One of them is crossorigin.me, a completely free (and open source) proxy which ......
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