Using FineUploader with optional https?

女生的网名这么多〃 提交于 2020-01-15 19:13:28

问题


I have setup FineUploader on a site and I included a check box that allows users to upload files using HTTPS if the want to.

Unfortunately if the user accesses the site using http and then tries to use ssl it errors out, I assume because of CORS issues. I assume it is a CORS issue because if I access the site using https and try to upload using ssl it works fine.

I found some documentation about enabling CORS support, but it appears that you either need to make it so only CORS requests will be made or none will be made. In my situation there will be CORS request some times and not others.

Does anyone know of a good work around for this? Should I just reload the entire page using HTTPS when the checkbox is clicked?


回答1:


Just to reiterate what I've mentioned in my comments (so others can easily see this)...

Perhaps you can instantiate Fine Uploader after the user selects HTTP or HTTPS as a protocol for uploads. If you must, you can enabled the CORS feature via the expected property of the cors option. Keep in mind that there are some details server-side you must address when handling CORS requests, especially if IE9 or older is involved. Please see my blog post on the CORS feature for more details.




回答2:


If you're uploading straight to Amazon s3, see the note in the official docs, "SSL is also supported, in which case your endpoint address must start with https://" in the script within your uploaderpage.html file.

request: {
    endpoint: 'https://mybucket.s3.amazonaws.com', 
                // Note that "https://" added before bucket name, to work over https                     
    accessKey: 'AKIAblablabla' // as per the specific IAM account
},
  • This will still work if uploaderpage.html is served over http (or you could populate the endpoint value dynamically if you need flexibility re endpoint).
  • This will help you avoid the mixed content error when uploading over https, "requested an insecure XMLHttpRequest endpoint", which happens if the page is https but you request a http endpoint.


来源:https://stackoverflow.com/questions/15815996/using-fineuploader-with-optional-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!