question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blitz and Sprig playing nicely together

See original GitHub issue

We have a form appearing in the footer of our site (so on every page). The site uses Blitz to cache the site and we are trialling sprig to load in the form component as well as handle the form responses.

The issue we are having is that the CSRF token that sprig is generating is being rejected.

For example, our page footer:

{{ sprig('/_components/newsletter/sign-up-mailchimp') }}
{{ sprig.script }}

Then our form code (stripped back/simplified):

<form sprig s-action="mud-module/default/mailchimp-subscribe" s-method="POST">
    {{ craft.blitz.getUri('/actions/snaptcha/field/get-field') }}
    <input type="text" name="email" required />
    <input type="submit" value="Submit" />
</form>

The error message is 400 Unable to verify your data submission implying an invalid CSRF token is being submitted.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
bencrokercommented, Sep 3, 2020

I’m not sure what your use-case is, but it should be noted that the format for this changed in version 1.0.0-beta.11 (https://github.com/putyourlightson/craft-sprig/blob/develop/CHANGELOG.md#100-beta11---2020-08-18).

{{ sprig('/_components/newsletter/sign-up-mailchimp', {}, {'s-trigger': 'load'}) }}
0reactions
bencrokercommented, Sep 10, 2020

This works in my local tests:

{{ sprig('_components/hello', {}, {'s-trigger': 'load'}) }}
{#--- _components/hello ---#}

{% if sprig.request %}
  Hello!
{% endif %}

Can you please double check that you are running 1.0.0-beta.13 which contains the following lines: https://github.com/putyourlightson/craft-sprig/blob/1.0.0-beta.13/src/services/ComponentsService.php#L171-L173

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sprig Plantar/Relationships - Disney Wiki - Fandom
They often played together (often making practical jokes or ambush the other) and were occasional sparring partners. Their relationship has been very mutual, ......
Read more >
News and Announcements Archives — Sprig Learning
For many reasons, 2022 was a fantastic year for Sprig Learning. Sprig is better equipped than ever to address the early learning issues...
Read more >
Amphibia - Sprig and Ivy moments - YouTube
Sprigivy is the romantic pairing between Ivy Sundew and Sprig Plantar.Episodes:"Dating Season" - While walking in the woods, Anne and Sprig ...
Read more >
Sprig Cookbook - PutYourLightsOn
Sprig allows you to create reactive components from Twig templates. ... Blitz. Load another. {# Passes a variable called `limit` into the component ......
Read more >
Sprig Taps Celebrity Chefs For Its On-Demand Dinner Service
Brioza's recipes will make up Sprig's first celebrity chef menu, ... and we worked on the recipes together to meet specifications.”.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found