1

I have build a small hello world app with composure and htmx:

    (defroutes app-routes
  (GET "/" [] "
<html>
<script src=\"https://unpkg.com/[email protected]\"></script>
  <!-- have a button POST a click via AJAX -->
  <button hx-post=\"/clicked\" hx-swap=\"outerHTML\">
    Click Me
  </button>
</html>
")

  (POST "/clicked" [] "
<html>
<body>
Hell
<\body>
</html>
")

But when I click on the button, I get [email protected]:1 Response Status Error Code 403 from /clicked

Why is that?

4
  • 1
    If you check in the browser's DevTools Network panel, does the response have any body? Do you have any Ring middleware configured? Nov 18 at 21:06
  • @EugenePakhomov I get url -X POST localhost:3000/clicked <h1>Invalid anti-forgery token</h1>% in the bash
    – David
    Nov 18 at 21:30
  • 1
    It can be disabled, see: stackoverflow.com/questions/33132131/…
    – David
    Nov 18 at 23:05
  • 2
    Well, seems like you gotta make htmx set the CSRF header, somehow. Or disable the CSRF protection if you don't need it for some reason. Nov 19 at 8:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.