-1

I tried to send data to backend(Playframework ). Csrf filter is blocking my request from fronted (angular). How can I disable it? this warn came in backend - [warn] p.filters.CSRF - [CSRF] Check failed because text/plain for request /api/add-books

enter image description here

    +nocsrf
    POST   /api/add-book             controllers.HomeController.addBooks()

enter image description here

enter image description here enter image description here

I tried these-

play.filters.desabled += play.filters.hosts.AllowedHostsFilter
play.filters.desabled += "play.filters.csrf.CSRFFilter"

But the problem is still there

  • You could probably take a look at this post : https://stackoverflow.com/questions/19966707/cors-error-on-same-domain – Tom Taylor Dec 03 '18 at 16:58

1 Answers1

0

Your spelling is wrong, correct it into:

play.filters.disabled += play.filters.hosts.AllowedHostsFilter
play.filters.disabled += play.filters.csrf.CSRFFilter

If you are using compile-time dependency injection, configuration above will be ignored. Instead you need put code into your custom ApplicationLoader.

Here is the official documentation:

Compile Time Default Filters