Expand my Community achievements bar.

Not able to save user profile data due to CSRF token error

Avatar

Level 2

We are getting error while posting data using POST servlet on "Stage environment".

User are not able to save their profile data due to CSRF token error (PFA error log). We have created POST servlet in AEM to save profile data like profile image, about section etc.

Note: The above error is occurring occasionally.

Thanks,

csrf_error.pngcsrf_header.png

4 Replies

Avatar

Level 10

are you using OOTB cq.jquery to post data or using from your own clientlib?

Thanks

Avatar

Level 2

Yes, I am using OOTB cq.jquery which is included in clientlibs.

AEM version: AEM 6.1 SP1

Sometimes POST Servlet is not working due to 403 error in console, see below -

1332686_pastedImage_0.png

Avatar

Level 10

Use AEM version of JQuery - it handles the token you need.

Avatar

Level 1

If the request is coming from outside AEM(some third party application) then you can exclude the post servlet path in the CSRF filter configuration. Also, if you are using AEM 6.3 then you can configure Cross Origin configuration to allow requests(Post, put, delete) from trusted domains.