Reputation: 853
I have an app that works fine on local but when i deploy to heroku javascript not loading properly.i have seen many problems related to this on stackoverflow.but didnt work.
file that contain javascript
<div id="myPublisherDiv"></div>
<div id="subscribersDiv"></div>
<script src="http://static.opentok.com/v2/js/opentok.min.js" type="text/javascript"></script>
<script>
alert("helloworld")
var apiKey = XXXXXX;//my apikey
var sessionId ="<%=@sessionId%>" ;
var token = "<%=@opentok_token%>";
var session;
OT.setLogLevel(OT.DEBUG);
session = OT.initSession(apiKey,sessionId);
var subscriberOptions = {
insertMode: 'append',
width: 340,
height: 260,
align: 'center'
};
session.on
({
streamCreated: function(event)
{
session.subscribe(event.stream,'subscribersDiv',{insertMode: 'append',width:340,height:260});
}
});
session.connect(token,function(error){
if(error)
{
console.log(error.message);
}
else{
session.publish('myPublisherDiv',{width: 300,height: 220});
}
});
</script>
nothing executed except alert function added above.
in application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .
gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.23.0'
gem 'opentok'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem "omniauth-google-oauth2", "~> 0.2.1"
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
gem 'sqlite3'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg'
gem 'rails_12factor'
gem 'puma', '2.11.1'
end
i added in production.rb
config.assets.compress = true
and onething i have to say is i developed same app with other specifications without using bootstrap.it worked fine on heroku. but in this app i used bootstrap i guess this may be the issue.please help me.
updated in browser console it shows
Upvotes: 4
Views: 145
Reputation: 20033
The error you're getting is quite self explanatory.
Your web app is configured to use HTTPS but it has dependencies on HTTP.
Changing
<script src="http://static.opentok.com/v2/js/opentok.min.js" type="text/javascript"></script>
to
<script src="https://static.opentok.com/v2/js/opentok.min.js" type="text/javascript"></script>
will fix your problem.
Upvotes: 4