-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
How to setup Koa reverse proxy to all “/api” requests to by-pass CORS communication with API server? #455
Comments
I'm usually on IRC and willing to help. There's also a the mailing list. Try koa-cors? |
Does this help? https://www.npmjs.com/package/koa-pixie-proxy |
@cesarandreu tnx man. I'll reach out. @jedrichards I totally had no luck with that one or koa-proxy or koa-http-proxy. Actually with any solution I found online (that's why I posted here, I guess it would be of a benefit for others too). |
Oh, I see. Previously I've wrapped node-http-proxy for one of my apps... But it's a bit different. But for your problem, it seems like CORS-Proxy and cors-anywhere would be good references for making your own wrapper. |
I'd be interested to hear how you get on with this. I'm writing an app with a very similar tech stack (isomorphic React, Flux, Koa). At the moment I'm writing my REST API endpoints in Koa, but eventually I could see needing to separate the API out, at which point I'll have exactly the same problem as you. There seems to be relevant discussion in this issue: #198 Basically seems to be using node-http-proxy directly in Koa, and setting |
can we close this? like i said #198 (comment), i would actually not use koa for proxying - use something closer to node's API. also, i'm not exactly sure what the problem is. |
I'm not sure what the problem is either. I don't see why there can be any koa-specific problems to proxy and cors :) @g6scheme Let us know if this can be closed |
Is #198 (comment) a fairly complete example? It looks good to me, but how do we then make use of the I think as people make more isomorphic apps, needing a thin Node-based static file server and isomorphic app renderer will be a very common requirement that people will gravitate towards Koa for. It'd be nice to either have a super clear example of API request proxying on a Koa route, or some middleware that worked out of the box. If #198 (comment) is that example I would say this issue is close-able :) |
Thanks guys. |
@jedrichards i agree and would like to see a more fleshed out example. setting up an isomorphic react app that proxies |
I'd love to see updates. |
@ngduc I'm on my phone but try this: app.use(mount('/api', cors())); Where mount is koa-mount and cors is koa-cors. |
Hi guys,
Is there any good example or documentation for this type of thing?
Currently I cannot setup CORS on API server reverse proxying API calls is only option.
Reverse proxy setup should proxy all calls to the /api and should not trim headers standard and custom both ways.
Application is Node app build with Koa, React, Flummox, React router etc.
Thanks
The text was updated successfully, but these errors were encountered: