Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add Edge-related material #740

Merged
merged 5 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions docs/data/routes/docs/nextjs/deploying-to-production/vercel/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ This guide will demonstrate deploying the Next.js sample app that's generated by
1. Execute the steps provided in the Next.js guide for [Getting Started](https://nextjs.org/docs/deployment#getting-started) with deployment.
2. Add [environment variables](https://nextjs.org/docs/basic-features/environment-variables#environment-variables-on-vercel) to Vercel or modify `.env` file. We recommend to use environment variables in Vercel:
* `PUBLIC_URL` - your Vercel deployment URL.
* `SITECORE_API_KEY` - your Sitecore API key. For Sitecore XM, the `SITECORE_API_KEY` will be your Sitecore SSC API key. For Sitecore Experience Edge, this will be the API key provisioned here.
* `SITECORE_API_KEY` - your Sitecore API key. For Sitecore XM, the `SITECORE_API_KEY` will be your Sitecore SSC API key. For Sitecore Experience Edge, this will be the [API key provisioned here](https://doc.sitecore.com/developers/101/developer-tools/en/test-your-queries.html).
* `SITECORE_API_HOST` - your Sitecore API hostname. The `SITECORE_API_HOST` is not required for Sitecore Experience Edge.
* `JSS_EDITING_SECRET` - your secret token. The `JSS_EDITING_SECRET` is optional for deployments but necessary if you want to use the Experience Editor with your Next.js Vercel deployment. Read about [connecting your Next.js application to the Experience Editor](/docs/nextjs/experience-editor/walkthrough).
* `GRAPH_QL_ENDPOINT` - your GraphQL endpoint. The `GRAPH_QL_ENDPOINT` is required for Sitecore Experience Edge. For Sitecore XM, this is typically optional. By default, the endpoint is calculated using the resolved Sitecore API hostname + the `graphQLEndpointPath` defined in your `package.json`.
3. Push the changes to your Git provider.

## Video demonstration

<p>
Watch the following video to see the deployment process and get some tips.
<iframe width="672" height="378" src="https://www.youtube.com/embed/s_F5hoNsvOo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</p>

## `publish:end` webhook invocation

Using the `publish:end` webhook, you can automatically trigger static site generation, cache clearing, and other automated activities with webhook support.
ancaemcken marked this conversation as resolved.
Show resolved Hide resolved

To enable the `Publish:end` hook, you must:
To enable the `Publish:end` hook:

1. [Create a deploy hook](https://vercel.com/docs/more/deploy-hooks#creating-a-deploy-hook) in Vercel.
2. Create webhook config based on example `/App_Config/Sitecore/JavaScriptServices/Sitecore.JavaScriptServices.AppServices.PublishingWebHook.config.example`, and include it in your solution:
Expand All @@ -33,9 +40,26 @@ To enable the `Publish:end` hook, you must:
4. Publish items.
5. On Vercel, check that the end of the publishing process triggered a new deployment.

## Video demonstration
## Webhooks on Edge

<p>
Watch the following video to see the deployment process and get some tips.
<iframe width="672" height="378" src="https://www.youtube.com/embed/s_F5hoNsvOo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</p>
Instead of triggering a webhook when the publishing process finalizes in Sitecore, if you are using Sitecore Experience Edge, you can trigger webhooks when your data reaches the Edge Delivery Platform.

You can register, update, remove or list webhooks with the help of the Experience Edge [Admin API](https://doc.sitecore.com/developers/101/developer-tools/en/admin-api.html).

> Before using the Admin API for any operations, make sure to [obtain an authentication token](https://doc.sitecore.com/developers/101/developer-tools/en/request-a-jwt-for-experience-edge-xm-using-oauth.html).

To trigger a new deployment on Vercel when your data reaches the Edge Delivery Platform:

1. [Create a deploy hook](https://vercel.com/docs/more/deploy-hooks#creating-a-deploy-hook) in Vercel and copy the URL of the webhook.
2. Send a `POST` request to the Admin API webhook endpoint `https://edge.sitecorecloud.io/api/admin/v1/webhook` as follows:
```json
{
"label": "My new webhook",
"createdBy": "SOME_USER_ID",
"uri": "YOUR_VERCEL_WEBHOOK_URL",
"method": "GET"
}
```
3. To verify the request completed successfully, check that you received a `201 Created` response status code.
4. Make some changes in Sitecore and publish.
5. When the Experience Edge finishes processing the new data, the publishing process is complete and Vercel should start a new deployment.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ You can set the following environment variables to configure the SSR sample inst
| Parameter | Description |
| ----------------------------------- | ------------------------------------------------------------ |
| `SITECORE_JSS_APP_NAME` | The JSS app's name. Used when request layout data and dictionary using graphql query and the default value of `SITECORE_JSS_SERVER_BUNDLE` if not set. |
| `SITECORE_API_KEY` | The API key provisioned on Sitecore Experience Edge. |
| `SITECORE_API_KEY` | [The API key provisioned on Sitecore Experience Edge.](https://doc.sitecore.com/developers/101/developer-tools/en/test-your-queries.html) |
| `SITECORE_JSS_SERVER_BUNDLE` | Path to the JSS app's `server.bundle.js` file. |
| `SITECORE_EXPERIENCE_EDGE_ENDPOINT` | Sitecore Experience Edge endpoint. |
| `DEFAULT_LANGUAGE` | The JSS app's default language. Used to determine language context if language unspecified in the request URL. |
Expand Down