Unable to upload a PDF file using the file endpoint


#1

Hi,

I have been successfully uploading PDF objects to the File (System) artifact on my GraphCool project. From today, however, I am getting the following CORS error. It was working fine till yesterday. Did something change on the server side? I am using the legacy GraphCool console project.

Code:
_uploadFile(e){
e.preventDefault();
var self = this;
const {id} = this.props.circular;
var fd = new FormData();
var file = document.getElementById(‘file’).files[0];
fd.append(‘data’, file)
var fileName = file.name;
$.ajax({
url: Environment.GCOOL_FILE_ENDPOINT,
data: fd,
type: ‘POST’,
// THIS MUST BE DONE FOR FILE UPLOADING
contentType: false,
processData: false,
// … Other options like success and etc
success: function(data){
console.log(“UPLOAD SUCCESS:”, data);
let fileId = JSON.parse(data).id;
self.props.addToCircularOnFile({variables: {filesFileId: fileId, circularCircularId: id}})
.then((res) => {
console.log(“Updated Circular with files”, res.data);
//self.props.router.replace(’/viewActs’)
})

			},
			error: function(data){
				console.log("UPLOAD ERRRRRR:",data)
			}
		});
	}

Error:
[Error] Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
[Error] XMLHttpRequest cannot load https://api.graph.cool/file/v1/ due to access control checks.
[Log] UPLOAD ERRRRRR: – Object (bundle.js, line 140955)
Object
[Error] Failed to load resource: Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. (cizao5xe14rfp0166d827jbmn, line 0)
Access to XMLHttpRequest at ‘https://api.graph.cool/file/v1/cj5end6wknyg2012294at79js’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.