VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
407 stars 63 forks source link

JWT Authentication fails #84

Closed agodima closed 2 years ago

agodima commented 2 years ago

Hello to everyone and thanks for your work. I have a Reviews collection with a reference to Comments. My application uses JWT Authentication. When I try to post a new Comment in the following way:

const config = { method: 'POST', headers: { Authorization: Bearer ${idToken}, Accept: 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(comment) };

try { const response = await fetch(api, config); result = await response.json(); return result } catch (error) { console.log(error) }

it fails with the following response:

{ "statusCode": 401, "error": "Unauthorized", "message": "Invalid token." }.

I saw in the configuration section of the README.md file that i should add in config/custom.js the following snippet:

plugins: { comments: { enableUsers: true, badWords: false }, },

but I don't see any custom.js file in my project. How should I have to integrate the JWT Authentication with the plugin?

Thank you for your time.

cyp3rius commented 2 years ago

With version 1.0.4 we've release configuration source file change. Refer to the updated documentation: https://github.com/VirtusLab-Open-Source/strapi-plugin-comments#configuration