strapi / strapi-starter-gatsby-corporate

strapi-starter-gatsby-corporate-git-main-strapijs.vercel.app
MIT License
27 stars 8 forks source link

Preview mode #23

Open lperozzi opened 3 years ago

lperozzi commented 3 years ago

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

markkaylor commented 3 years ago

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
lperozzi commented 3 years ago

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 commented 3 years ago

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

markkaylor commented 3 years ago

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

lperozzi commented 3 years ago

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?

markkaylor commented 3 years ago

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.

lperozzi commented 3 years ago

@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