Skip to content
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

CORS error when uploading via S3 file adapter #722

Closed
davidruisinger opened this issue Feb 29, 2016 · 5 comments
Closed

CORS error when uploading via S3 file adapter #722

davidruisinger opened this issue Feb 29, 2016 · 5 comments

Comments

@davidruisinger
Copy link

Environment Setup

Parse Server running on AWS elastic beanstalk with configured S3 files adapter.

  ...
  filesAdapter: new S3Adapter(
    "****",
    "****",
    "my-bucket",
    {
      bucketPrefix: "files/",
      directAccess: true
    }
  )
  ...

Steps to reproduce

Using the JS SDK from an external Website to upload an Image:

  var parseFile = new Parse.File(name, file, type);
  parseFile.save().then(function() {
  ...

Logs/Trace

Error in chrome:

XMLHttpRequest cannot load http://myelasticbeanstalkURL.com/parse/files/RNLDeC7GCT.png. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http:/myexternalURL.com' is therefore not allowed access.
@flamesoft
Copy link

I believe the issue is what Parse is trying to solve in this thread [https://github.com/parse-community/parse-server-example/issues/53].
BTW, please show how you made it if you succeed to upload file with S3. Thanks!

@flovilmart
Copy link
Contributor

Fixed with #876

@pascalgiguere
Copy link

I'm still getting this issue when using the S3Adapter.

No 'Access-Control-Allow-Origin' header is present on the requested resource.

This is only a problem when saving files, all other requests are fine.

@flovilmart
Copy link
Contributor

flovilmart commented May 25, 2016

What call are you issuing?

@pascalgiguere
Copy link

pascalgiguere commented May 25, 2016

Client code:

var myFile = new Parse.File('photo.jpg', bytes);
myFile.save().then(function() {
    myObject.set('image', myFile);
    myObject.save();
});

General:

Request URL:https://myapp.herokuapp.com/parse/classes/myClass/Ym40Fke4m5
Request Method:POST
Status Code:503 Service Unavailable
Remote Address:54.243.123.255:443

Request headers:

Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8,fr;q=0.6
Connection:keep-alive
Content-Length:541
Content-Type:text/plain
Host:myapp.herokuapp.com
Origin:http://localhost:8000
Referer:http://localhost:8000/myPage.html
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
x-ijt:p3b2a2fs5qoldcphug0cstd1m9

Response headers:

Cache-Control:no-cache, no-store
Connection:keep-alive
Content-Length:484
Content-Type:text/html; charset=utf-8
Date:Wed, 25 May 2016 20:49:02 GMT
Server:Cowboy

Request payload:

_ApplicationId: "(censored)"
_ClientVersion:"js1.6.14"
_InstallationId:"(censored)"
_JavaScriptKey:"(censored)"
_method:"PUT"

(All my object attributes)
[...]

Error log:

XMLHttpRequest cannot load https://myapp.herokuapp.com/parse/classes/myClass/Ym40Fke4m5.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8000' is therefore not allowed access.
The response had HTTP status code 503.

The file saving works. POST https://myapp.herokuapp.com/parse/files/photo.jpg goes through and I can see the file in my S3 bucket.

It's really just saving the object right after that doesn't work. Saving the same object without setting the file works.

The same request will also work fine if I run Parse Server locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants