strapi-starter-gatsby-corporate icon indicating copy to clipboard operation
strapi-starter-gatsby-corporate copied to clipboard

Preview mode

Open lperozzi opened this issue 3 years ago • 7 comments

I tried to follow the Preview mode step but I'm lost. Where can i find a .env.development.example, to copy?

lperozzi avatar Aug 18 '21 09:08 lperozzi

Hi @lperozzi sorry it looks like the .env.development.example doesn't exists :( I will add it ASAP but you can create a .env.development file with:

GATSBY_PREVIEW_SECRET=a-very-secret-token

markkaylor avatar Aug 18 '21 10:08 markkaylor

Ok, thanks for reply. You add this file at the root level right? i.e. same level as the frontend and backend folder ? Many thanks for your help

On Wed, 18 Aug 2021, 12:31 markkaylor, @.***> wrote:

Hi @lperozzi https://github.com/lperozzi sorry it looks like the .env.development.example doesn't exists :( I will add it ASAP but you can create a .env.development file with:

GATSBY-PREVIEW-SECRET=a-very-secret-token

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/strapi/strapi-starter-gatsby-corporate/issues/23#issuecomment-901003738, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPJIYINFOSDDQP35UQQCMTT5ODXZANCNFSM5CLTMB2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

lperozzi avatar Aug 18 '21 10:08 lperozzi

After adding .env.development to the project folder with a secret token, when I go to the URL http://localhost:8000/en/preview/<slug>?secret=<secret-token> I have this message https://prnt.sc/1qa2tx2 , but I do not know what further action takes to turn preview mode on Thanks for your help

lperozzi avatar Aug 18 '21 11:08 lperozzi

The .env.development file needs to be added at the root of the frontend folder. Same level as gatsby-config.js for example. There is a video here: https://strapi.io/blog/strapi-starter-next-corporate-site that shows how to turn it on. Make sure you restart the server when you add or make changes to a .env file

markkaylor avatar Aug 18 '21 11:08 markkaylor

Many thanks for your help, now it works. Last question...to see the changes we always need to restart the server? Or there is an option for local development that allow to see changes in real time?

lperozzi avatar Aug 18 '21 11:08 lperozzi

When preview mode is turned on and you are accessing a preview page you do not need to restart the server, that page will fetch data on the client. Otherwise, yes, since Gatsby is a static site generator it needs to rebuild the site if you make changes in the Strapi admin backend.

markkaylor avatar Aug 18 '21 11:08 markkaylor

@markkaylor many thanks. At the beginning the preview mode did not update the changes, but I probably did something wrong. Now all works fine. Thanks for the support

lperozzi avatar Aug 18 '21 14:08 lperozzi