Hi @kbitra1998
CSRF protection is only available for authenticated user. So in author it will be passed while making any servlet call as you will be logged in.
But on Publish instance, if you are making any anonymous call, CSRF token will be empty as there will not be any authentication.
"The basic idea: Server provides a CSRF token to the client for all authenticated sessions. The client should pass the same CSRF token to the server with each subsequent request. So if a request came without the token, the server should ignore/log it. Your CSRF token should ideally only be passed to the client upon authentication."
"There are no tokens on the publish instances for anonymous users."
Access http://localhost:4503/libs/granite/csrf/token.json while logged in as an user, you will get value.
Access http://localhost:4503/libs/granite/csrf/token.json as anonymous user, you will get empty {}.
Please refer the below link for more info:
https://experienceleague.adobe.com/docs/experience-manager-65/developing/introduction/csrf-protection.html?lang=en
Thanks!