# 如何允许表单不带CSRF保护提交

**URL:** https://meta.discourse.org/t/how-to-allow-a-form-to-be-submitted-without-csrf-protection/293812
**Category:** Development
**Created:** [2024年二月1日 17:59 UTC](https://meta.discourse.org/t/how-to-allow-a-form-to-be-submitted-without-csrf-protection/293812 "2024-02-01T17:59:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2024年二月1日 17:59 UTC](https://meta.discourse.org/t/how-to-allow-a-form-to-be-submitted-without-csrf-protection/293812/1 "2024-02-01T17:59:17Z")

</div>

继续讨论 [通过 API 生成登录电子邮件](https://meta.discourse.org/t/generating-a-login-email-via-api/235737/4)：

> [@Falco](#):
>
> 而且你不能在没有 API 密钥的情况下调用它，因为这个路由受到 `:verify_authenticity_token` CSRF 保护。

但那正是我想要的，然后我搜索了源代码中的 `verify_authenticity_token`，并发现我可以使用

```plaintext
    skip_before_action :check_xhr, :preload_json, :verify_authenticity_token

```

来让我的插件接受一个 post！
