Skip to content

Refresh Tokens Cached on Craft Cloud #1963

@shennyg

Description

@shennyg

Describe the bug

Hey there. I'm launching a Craft Cloud site tomorrow and getting past some final QA bugs.

Looks like https://PROJECT-NAME-production-5cd1c590.preview.craft.cloud/actions/formie/forms/refresh-tokens?form=footerSignup is a GET and returning a cache HIT. Craft Cloud is cached using CloudFlare.

I am on Formie version 2.1.17 and I don't see any changes in the changelog since related to refresh tokens. I am looking at the latest on v4: https://github.com/verbb/formie/blob/craft-4/src/controllers/FormsController.php#L371-L398

It looks like we need to add $this->response->setNoCacheHeaders(); More info from Craft on opting out of caching here: https://craftcms.com/knowledge-base/cloud-static-caching#opting-out

As a hotfix I've done this, we are using your Cached Forms Advanced Usage approach:

 -       fetch('/actions/formie/forms/refresh-tokens?form={{ form.handle }}')
+        fetch('/actions/formie/forms/refresh-tokens?form={{ form.handle }}&cache-workaround=' + Math.random())

Thanks so much!

Steps to reproduce

  1. setup site in craft cloud
  2. set to production mode so caching is enabled
  3. setup advanced usage style cached form
  4. submit form twice and get a CSRF error

Form settings

  • Multi-page form: No
  • Submission Method: Ajax
  • Client-side Validation: Yes
  • Custom Form Templates: No

Craft CMS version

4.10.2

Plugin version

2.1.17

Multi-site?

No

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions