YUI 3 is going to yui.yahooapis.com to get the code. I am https and the content is locked

I worked on this holiday to find out that my code does not work on HTTPS. My LOCALDEV is HTTP, and our production server is HTTPS.

For some reason, YUI is going to get JS when I have it locally.

enter image description here

I have this on the server ...........

enter image description here

And finally, my code:

YUI().use('autocomplete', 'autocomplete-filters', 'autocomplete-highlighters', function (Y) { var notes = [ "Dr Follow Up Complete Notes", "Fax Document Notes", "Event Notes", "Email Information Notes", "Corresponding Document Notes", "Return Call Notes", "Admit Notes", "Discharge Notes", "Other Notes", "Excellent Resource Notes", "Good Resource Notes", "Neutral Resource Notes", "Poor Resource Notes", "Unacceptable Resource Notes", ]; var inputNode = Y.one('#name'); inputNode.plug(Y.Plugin.AutoComplete, { resultFilters : 'phraseMatch', resultHighlighter: 'phraseMatch', source : notes, minQueryLength : 0 }); inputNode.ac.get('boundingBox').setStyle('zIndex', 50); inputNode.on('focus', function () { inputNode.ac.sendRequest(''); }) 

==================================================== ==================================

THIS AFTER ADDITION: base: 'include / javascript / yui3 / build'

enter image description here

I do not have this directory in my assembly.

+6
source share
3 answers

TL; DR : try setting the base configuration property in your call to YUI.

I did not use YUI, but, generally speaking, requests from the HTTPS site should always go to other HTTPS sites (otherwise you will see insecure warnings about the content or requests will be blocked, as you discovered). So the problem.

You have 2 options that I can think of to fix this:

For example, if your YUI library is available at https://mydomain.com/static/js/yui_3.6.0/yui/build/ (and your page is located, say, https://mydomain.com/sample/page ), you can do the following:

 <script src="https://mydomain.com/static/js/3.6.0/yui/build/yui-min.js"></script> 

And then in your javascript files:

 YUI({ base: 'static/js/yui_3.6.0/yui/build/' }).use('node', 'event', function(Y) { ... }) 

(or perhaps base: '/static/js/yui_3.6.0/yui/build/' ; I do not have a server on which to test - please report what worked, if any!)

+8
source

I thought I would share my experience in the hope that someone else would be helped. May not work for others or not. I requested the following URL: http://yui.yahooapis.com/combo?2.6.0/build/yahoo-dom-event/yahoo-dom-event.js&2.6.0/build/animation/animation-min.js

But you need https, so I just changed it from http to https and received a security warning that the certificate is not valid for the domain. I looked at the actual domains and noticed "yui-s" and thought "Hmmmm secure version?"

Then I tried this: https://yui-s.yahooapis.com/combo?2.6.0/build/yahoo-dom-event/yahoo-dom-event.js&2.6.0/build/animation/animation-min.js

What worked wonderfully. Therefore, others just try to switch to https, and if your subdomain "yui" changes it to "yui-s"

Hope this helps someone

+20
source

It looks like you are serving the source file yui-min.js from the CDN. Find this:

 <script type="text/javascript" src="http://yui.yahooapis.com/..."></script> 

Replace this to point to your local copy of YUI:

 <script type="text/javascript" src="/where/you/put/yui/build/yui/yui-min.js"></script> 

This should work and serve the necessary JS from your local server.

However, this will not have any combo downloads that cause the page to load (sometimes much slower. You can read a good article on YUI combo downloads locally at http://blog.endpoint.com/2011/02/locally-served-yui3 .html

0
source

Source: https://habr.com/ru/post/924486/


All Articles