Gatsby Dynamic Rebuild Static Pages on Production

Viewed 399

I write my first Gatsby Page. I also use Laravel as backend server. In my project i have many slug pages. I used createPages and api connection to create them. User can add files like images, audio files and pdf. When it happen, page should change a bit content and show this file on specify address. Develop version works fine (i bind button to start npm run refresh). I used gatsby refresh endpoint and add to scripts:

"refresh": "curl -X POST http://localhost:8000/__refresh"

And it's work fine. But i don't know how change this to use it properly on production build. Can anyone help me? Thanks

1 Answers

The ENABLE_GATSBY_REFRESH_ENDPOINT environment variable is only working on development. According to the documentation:

During local development, it can be useful to refresh sourced content without restarting the development server. To facilitate this, Gatsby exposes an environment variable called ENABLE_GATSBY_REFRESH_ENDPOINT.

What you need is called a webhook. Basically, a webhook is a way for an application to trigger a change that happens in real-time in a CMS.

Each CMS has its own way of implementing webhooks, but the idea is to trigger a build process once a change in your CMS occurs.

Related