How can I force a js library to always load only via SSL?
Specifically, I want to get Drupal to always load stripe.js with SSL, because stripe.js refuses to load over http (you get a 403 FORBIDDEN error).
I'm loading stripe.js through the Commerce Stripe module.
commerce_stripe.libraries.yml
looks like this:
stripe:
remote: https://github.com/stripe/stripe-php
version: "4.3.0"
license:
name: MIT
url: https://github.com/stripe/stripe-php/blob/master/LICENSE
gpl-compatible: true
js:
"https://js.stripe.com/v3/": { minified: true }
So I thought this would be sufficient to always load via SSL.
On my production site, for which all the assets are SSL, everything works.
On Lando, my local development environment, everything is fine when I access my site from a browser installed on my machine, even when the connection to the locally hosted website is http (connection to my dev site is http, connection to stripe.js is https).
However, when using the Standalone Chrome Debug docker image to test my site with Behat, stripe.js doesn't load. I get a 403 FORBIDDEN error because the Chrome browser in the Standalone Chrome Debug container tries to load stripe.js via http.
From the Chrome browser with the problem, this is what the <script>
tag looks like for stripe.js:
<script src="//js.stripe.com/v3/"></script>
I'm not sure exactly why I am having this problem only with the Standalone Chrome Debug docker image, but I suspect it is because I cannot access my site via https from the image at all. However, in the browser, I can open other SSL sites such as https://www.google.com and perform a search without any problems.
So,
- If I am accessing a local installation of Drupal via docker from inside a docker container
- And I do not have access to the Drupal installation via HTTPS
- Is it impossible to load a third-party js library (stripe.js) via HTTPS?
The reason I'm confused is that I can load stripe.js locally when accessing my site via a browser in Windows (my dev machine) through http, but in the Docker container (standalone-chrome-debug), accessing my local dev site through http gets a 403 forbidden for stripe.js. (When I manually type the stripe.js library link into the browser, I can download the library, so the problem only occurs with the link/connection generated by Drupal.)