Skip to content

Custom Implementation

For your frontend to fully support Pyxis features (preview, revalidation), it must have a server-side layer (SSR/Edge) to securely store API keys.

Your engine should query the endpoint: GET {INTERNAL_API_URL}/api/pages/{slug}

  • The Accept: application/json header is required.
  • If a pyxis_preview cookie exists in the browser, its value must be forwarded in the X-Pyxis-Preview header.

You must create an endpoint (e.g., /api/preview) that:

  1. Receives path, expires, and signature parameters from the URL.
  2. Forwards them to {INTERNAL_API_URL}/api/preview/verify.
  3. If the response is successful, stores the received preview_token in a secure cookie (httpOnly).
  4. Redirects the user to the address specified in path.

If your framework uses caching (e.g., ISR/SSG), create a POST /api/revalidate endpoint that:

  1. Validates the REVALIDATE_TOKEN in the header or body.
  2. Upon successful verification, triggers a cache purge for the provided path.