1

I've recently added an SSL to the site I'm working on, and it seems to have broken my "load more" buttons via sprig. When I click the button now, I get

Blocked loading mixed active content “http://mydomainname.net/index.php?p=actions/sprig/components/render&offset=6&sprig%3AsiteId=32200a47f3a91660d5c53896017cd9e51baccf7f69c571407279fa99ecbcffb91&sprig%3Atemplate=0fb8ec651fc53258017209d22d4e19b6143ac209993784d01a06801fd13e9cd6_layouts%2F_blog%2F_loadMore&sprig%3Avariables%5Blimit%5D=15a1fe68dab9e8d01fdd3bc84980fa5d354e5c72f0e00d06e0841462638f363d6”

and

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.mydomainname.net/index.php?p=actions/sprig/components/render&offset=6&sprig%3AsiteId=32200a47f3a91660d5c53896017cd9e51baccf7f69c571407279fa99ecbcffb91&sprig%3Atemplate=0fb8ec651fc53258017209d22d4e19b6143ac209993784d01a06801fd13e9cd6_layouts%2F_blog%2F_loadMore&sprig%3Avariables%5Blimit%5D=15a1fe68dab9e8d01fdd3bc84980fa5d354e5c72f0e00d06e0841462638f363d6. (Reason: CORS request did not succeed).

errors in my console. I've noticed that the cross origin error is trying to load stuff over https but the mixed active content error is trying to load over http.

How can I get this working again over https?

Here's my sprig code if you need it:

{{ sprig('_layouts/_blog/_loadMore', {'limit': 6}) }}
{{ sprig.script }}
{% set offset = offset ?? 0 %}

{% set entryQuery = craft.entries.section('diggingDeeper').offset(offset).limit(limit) %}
{% set entries = entryQuery.all() %}

{% for entry in entries %}

    ----Entry Stuff----

{% endfor %}

            
{% if entryQuery.count() > offset + entries|length %}
  <button class="orange-button" sprig s-val:offset="{{ offset + limit }}" 
    s-target="this" s-swap="outerHTML">
    <p>Load More</p>
  </button>
{% endif %}

Edit: Added the full errors

Edit 2: Here is my .htaccess file that forces https and removes www

<IfModule mod_rewrite.c>
    RewriteEngine On

# send would-be 404 requests to craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]

# Force https
RewriteCond %{HTTP_HOST} mydomainname\.net [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mydomainname.net/$1 [R,L]

# Remove the www from the URL
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
</IfModule>

Edit 3: After resolving the "Blocked loading mixed active content" error these are the current errors in the console when the load more button is clicked

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.mydomainname.net/index.php?p=actions/sprig/components/render&offset=6&sprig%3AsiteId=32200a47f3a91660d5c53896017cd9e51baccf7f69c571407279fa99ecbcffb91&sprig%3Atemplate=0fb8ec651fc53258017209d22d4e19b6143ac209993784d01a06801fd13e9cd6_layouts%2F_blog%2F_loadMore&sprig%3Avariables%5Blimit%5D=15a1fe68dab9e8d01fdd3bc84980fa5d354e5c72f0e00d06e0841462638f363d6. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

htmx:afterRequest htmx-1.2.1.js:1368:25

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.mydomainname.net/index.php?p=actions/sprig/components/render&offset=6&sprig%3AsiteId=32200a47f3a91660d5c53896017cd9e51baccf7f69c571407279fa99ecbcffb91&sprig%3Atemplate=0fb8ec651fc53258017209d22d4e19b6143ac209993784d01a06801fd13e9cd6_layouts%2F_blog%2F_loadMore&sprig%3Avariables%5Blimit%5D=15a1fe68dab9e8d01fdd3bc84980fa5d354e5c72f0e00d06e0841462638f363d6. (Reason: CORS request did not succeed).

htmx:sendError htmx-1.2.1.js:1368:25

2

Sprig will use whatever your site's base URL is set to, to construct the action URL. Ensure in Settings → Sites that the base URL is either set to an absolute path starting with https://, or if an alias or environment variable, that it is defined as an absolute path starting with https://.

Also be sure to either force the www subdomain or force a naked domain. in your example above I see one with and one without www.

6
  • Just double checked, the base URL is already set to use https://. Is there some kind of sprig cache or database that is remembering old non-ssl paths that i need to clear? I already tried clearing the caches in craft, and uninstalling/re-installing sprig – Justin Kendall Mar 27 at 12:48
  • Updated my answer to include forcing the www subdomain or a naked domain. – Ben Croker Mar 27 at 16:27
  • I am forcing it to remove www in my .htaccess file (I updated my question to include that info). Is there a better way of doing that? – Justin Kendall Mar 27 at 17:06
  • So I just realized in looking at the forcing www to be removed that it is http not https. I just added the "s" and that got rid of the "Blocked loading mixed active content" error, but I still have the cross origin error. – Justin Kendall Mar 27 at 17:10
  • Updated question with current errors – Justin Kendall Mar 27 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.