I apply the CSRF in Controller by adding this:
class ApplicationController < ActionController::Base
protect_from_forgery
end
and I do a post request to my API using Postman. The funny result is I can't verify CSRF, but the data I send still be inserted into DB.
Here is the server log.
Processing by Api::ListingsController
Parameters: {"listing"=>{...}}
Can't verify CSRF token authenticity
(0.2ms) BEGIN
SQL (0.6ms) INSERT INTO "listings" ...
(0.4ms) COMMIT
Completed 201 Created in 54ms (Views: 0.2ms | ActiveRecord: 6.3ms)
Seems everything is fine, and data is in DB now! Why is CSRF not working?
Anyone can give any explains?