OPTIONS preflight request (CORS)


#1

Hi community!
My application listen port 8080, so it accessed with default workspace url. Also I have server for static files ran on port 8081. Before sending file using POST-request, browser performs OPTIONS-request (CORS) to port 8081. But static-server does not receive this request because of c9 system makes redirect to login page.

Here is general info about request:
Request URL:https://myapp.c9users.io:8081/
Request Method:OPTIONS
Status Code:302 Moved Temporarily
Remote Address:130.211.111.104:8081

This is a responce headers:
HTTP/1.1 302 Moved Temporarily
Location: https://c9users.io:8081/_user_content/authorize?redirect=https%3A%2F%2Fmyapp.c9users.io%2F
Date: Fri, 22 Jan 2016 05:27:17 GMT
Transfer-Encoding: chunked
X-BACKEND: apps-proxy

Is this a bug, or I doing something wrong?


XMLHttpRequest cannot load [url] Response for preflight is invalid (redirect)
Fetch API error when using Webpack devServer proxy
#2

Hi,

Thank you for writing in. It looks like you might have your application set to private, so the Cloud9 authentication is showing up. You can make your application public (and still keep your code private), by clicking on ‘Share’ near the top right of the IDE, and checking Public next to ‘Application’.

Regards,
​Mutahhir

Some related questions on StackOverflow:


#3

Thank you! It works.
Is there way to keep application private in this case?


#4

If you’re connecting to the application via an external service / app, there’s currently no way AFAIK.

Thinking more about this, hmm… There might be a way to add your authorization token to your external request that authorizes the request, but I’m not sure how that can be done. I’m going to leave this open for our engineers to see if someone knows of a good way to do this.

Regards,
​Mutahhir