I'm getting this error whenever I try to upload a ...
# prisma-whats-new
s
I'm getting this error whenever I try to upload a file:
Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin '<http://localhost:4200>' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Using the ng2-file-upload module which has been uploading to graphcool just fine until I tried it today. Any thoughts?
n
@stevewpatterson hey there! did you recently add any browser extension maybe? 🙂 or did you change your code?
s
@nilan Hi, no browser extensions. I havent changed my code at all but it is possible the ng2-file-upload library has been updated and it broke something, which is what im looking into now
I also was messing with a function on File is Created to validate file size/contentType, and I had some permission queries set up on on the File Object. I since turned all of those off though and tried it again but I still get the same error message
n
It looks to be a CORS issue, that's why I asked if you added an extension recently
Is there a way to control the
Access-Control-Allow-Credentials
header with
ng2-file-upload
? 🙂
If that doesn't help, please create an issue here: https://github.com/graphcool/api-bugs/issues
s
Youre right, ng2-file-upload was setting the withCredentials flag on the XMLHttpRequest to true by default. Manually, setting it to false fixed the issue.
n
Awesome! Could you please share a minimal working solution for a file upload in a new issue here? https://github.com/graphcool/content
I'm compiling a list of file upload examples
s
sure thing!
n
much appreciated! 🙌
Just saw the snippets, that's great, thanks