I have an articles model to which I want to add images, using active storage installed for uploading images via the form. Active storage works fine, both locally and in production with upload to Amazon s3.
However, I'm also using froala. When trying to insert an image to froala editor, I get this error (in the browser) : XHR OPTIONS https://undefined.amazonaws.com/undefined
article_controller.rb
def nouveau # new
@auteur = Auteur.find(session[:auteur])
@article = Article.new
@auteur.articles.build
options = {
bucket: '', # my bucket
region: 'eu-west-1',
keyStart: 'uploads',
acl: 'public-read', # I **think** this is correct
accessKey: '', # my access key, like active storage
secretKey: '' # my secret key, like active storage
}
@aws_data = FroalaEditorSDK::S3.data_hash(options)
end
the javascript that goes with it:
var editor = new FroalaEditor('#article_contenu',{
height: 330,
iframeStyleFiles: ['fr_moi.css'],
pluginsEnabled: ['image', 'link','align','charCounter','colors','fontAwesome','fontSize','fullscreen','image','link','lists','paragraphFormat','paragraphStyle','quote','url'],
placeholderText: 'Incipe scribere...',
paragraphFormat: {
N: 'normal',
H2: 'titre 2',
H3: 'titre 3'
},
imageUploadToS3: '<%= @aws_data.as_json.html_safe %>',
toolbarButtons:
// and so on. The js file is working correctly
I get the something went wrong. Please try again message in the froala editor. Browser responds:
XHR OPTIONS https://undefined.amazonaws.com/undefined
« Same Origin » policy doesn't allow consulting the distant resource on https://undefined.amazonaws.com/undefined. Reason : failure CORS request.