strapi-plugin-preview-button icon indicating copy to clipboard operation
strapi-plugin-preview-button copied to clipboard

How to add secret token?

Open bnsx opened this issue 1 year ago • 4 comments

http://localhost/preview?type=article&slug=game&secret=JWT_TOKEN_HERE

When i config jwt in config/plugins.js isn't work

I mean jwt token will generate 1 time not every time

expected : i want jwt token generate every time when i open link.

bnsx avatar Aug 04 '23 09:08 bnsx

did you try to execute a function there someUrl&secret=generateSecret()

kristijorgji avatar Aug 08 '23 13:08 kristijorgji

You can create one endpoint and call it to generate a real-time secret, thats what i did

kristijorgji avatar Aug 21 '23 17:08 kristijorgji

@kristijorgji How about if I want to pass some identifier(id) to the generateSecret()?

tapornanan avatar Sep 12 '23 08:09 tapornanan

@tapornanan I did exactly this and works fantastic.

Create one api endpoint and call it in the build preview url hook by sending all the entity data. Then you can use the id while creating the secret every time you create the preview url.

It works great, it also means that you make 2 api calls every time you open a content that is in draft mode to generate the preview url.

kristijorgji avatar Sep 18 '23 09:09 kristijorgji