HomeAdmin ManualHelpSpot HacksDisabling CSRF For A URL

15.2. Disabling CSRF For A URL

Cross-site request forgery (CSRF) protection can block HTTP POST requests that originate from a different site or external system. When this happens, the application may return a 419 Page has expired error during login or form submission.

Disabling CSRF for a specific URL can be used as a workaround when a POST must be accepted from an external source. This should be a last resort. Using a dedicated API endpoint for programmatic access is almost always a better and more secure approach.

When to consider disabling CSRF for a URL

Important security considerations

Disable CSRF protection for a specific URL

Step-by-step

  1. Open the application’s .env file.
  2. Add (or update) the DISABLE_CSRF setting to the exact URL that needs to accept the external POST.
DISABLE_CSRF="https://example.com/path/to/endpoint"

What to expect

This page was: Helpful | Not Helpful