Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require.js working with HTTPS, but HTTP #1350

Closed
saschazar21 opened this issue May 17, 2015 · 2 comments
Closed

Require.js working with HTTPS, but HTTP #1350

saschazar21 opened this issue May 17, 2015 · 2 comments

Comments

@saschazar21
Copy link

I'm trying to build a single-page-app with Express 4.x, Backbone.js and Require.js.
Deployed locally and on a server in the network, it loads the modules fast and flawlessly when requested via https. When requested via http, fetching certain modules fails randomly.

Nearly tried everything, waitSeconds, domReady, etc... Same behaviour on my local machine (Mac), as well as remotely on my LAN (Debian).

When reloading several times, the contents are getting rendered in the end...

config.js:

requirejs.config({
  baseUrl: 'js/',   // Needed for global loading
  waitSeconds: 30,
  paths: {
    backbone: 'vendor/backbone-min',
    bootstrap: 'vendor/bootstrap.min',
    domReady: 'vendor/domReady',
    dropzone: 'vendor/dropzone',
    gmaps: 'vendor/gmaps',
    hbs: 'vendor/handlebars/hbs',
    jquery: 'vendor/jquery-2.1.3.min',
    router: 'boot/router',
    underscore: 'vendor/lodash.min',
    require: 'vendor/require'
  },
  hbs: {
    disableI18n: true,
    disableHelpers: true,
    partialsUrl: '../templates/partials'
  },
  shim: {
    backbone: {
      deps: ['underscore', 'jquery'],
      exports: 'Backbone'
    },
    bootstrap: {
      deps: ['jquery']
    },
    gmaps: {
      exports: 'GMaps'
    },
    jquery: {
      exports: '$'
    },
    underscore: {
      exports: '_'
    }
  }
});

requirejs([
  'domReady',
  'boot/engine',
  'boot/launch'
], function(domReady, Engine, Launch) {
  domReady(Engine.haul);
  domReady(Launch.initialize);
});

launch.js:

define([
  'backbone',
  'router'
], function(Backbone, Router) {

  var launchSequence = function() {

    var router = new Router();

    if (!Backbone.history.started) {
      Backbone.history.start({pushState: true, root: '/'});  
    }
  };

  return {
    initialize: launchSequence
  };
});

engine.js: Just calls a jQuery POST function.

A screenshot from Safari:
bildschirmfoto 2015-05-17 um 21 12 48

@jrburke
Copy link
Member

jrburke commented May 26, 2015

If the test page that loads require.js is on an https: URL, then I can see that as a problem, you are then probably hitting mixed content issues (https trying to load http) and I can see the browser not allowing that.

Other than that, I expect some issue with the server/network/browser setup, and not something specific to requirejs as it does not favor http or https, just uses whatever is configured. So will close, but feel free to continue discussion here.

@jrburke jrburke closed this as completed May 26, 2015
@saschazar21
Copy link
Author

Thanks for your reply, I think I found a "workaround" which works better than my initial approach...

Using the (previously unknown) concatenation-possibility of r.js seems to fix any issue which occurred previously, also speeds up the whole setup. Anyhow, using the initial setup without concatenation while developing seems to only work when used over HTTPS...

So basically I'm fine with this solution, as I would make use of r.js for the production-ready branch anyhow - but the issue seems to remain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants