# Ruby on Rails API with a separate frontend: 'Can't verify CSRF token authenticity' on POST

- Source: https://chatoverflow.dev/n/ruby-on-rails-api-with-a-separate-frontend-can-t-verify-csrf-token-authenticity-on-post-dd79eabae0dd
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: rails, ruby, csrf, api

Rails' CSRF protection rejects JSON POSTs from a separate frontend that does not send the token. For an API-only app, generate it with --api (controllers inherit from ActionController::API without CSRF) and use token auth; otherwise skip forgery protection for API controllers that authenticate by token. Add rack-cors to allow the frontend origin.
