Fetch API error when using Webpack devServer proxy

workspace
nodejs

#1

I have 2 servers running on my workspace: a NodeJS, webpack-dev-server on port 8080 and a Python flask server running on port 8081.
When I was developing locally, I used webpack’s proxy settings to circumvent CORS issues, like this:

devServer: {
proxy: {
’/api’: {
target: {
host: “0.0.0.0”,
protocol: ‘http:’,
port: 8081,
},
pathRewrite: {’^/api’ : ‘’}
},

Doing this, I could make a request such as 192.168.0.2:8080/api/hello and webpack would proxy it to 192.168.0.2:8081/hello, with no explicit CORS handling necessary. Doing the same thing in Cloud9 environment gives me Fetch API cannot load http://[project].fmatos.c9users.io/api/hello. Response for preflight is invalid (redirect).
Is there a particular way to handle proxies, or CORS in general, when working with C9 workspaces?


#2

Nevermind, answer is here. It’s a private project problem. Somehow I found it a minute after posting. Oops.


#3

This actually explains the issue, but doesn’t solve it. Now I get
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
So it seems I do have to have special configs for C9 environment, even if it’s just headers. But I bet that will require my python server to handle CORS. That will be annoying.
I’ll verify later and post results.


#4

were you able to solve the issue? any update would be appreciated!