Skip to content

Commit

Permalink
Make URLs in search results absolute, clean up docs links, fix redire…
Browse files Browse the repository at this point in the history
…ct script (#1132)

Currently, because our docs site [uses client-side
routing](https://ngrok.slack.com/archives/C03LRGNSG6A/p1736881450186529?thread_ts=1736867844.224459&cid=C03LRGNSG6A),
our redirect script is not run when users visit links that use a
relative path. (This is not relevant to users who visit the docs from
external links)
- When you click on links to routes that need to be redirected, no
redirection happens.
- If there is no page at the route when redirection fails, you get a
404.

This affects all links in the docs, and all docs search result items.
(This issue does not affect Google search results)

Example: On [this
page](https://ngrok.com/docs/traffic-policy/getting-started/agent-endpoints/cli/#step-3-test-it-out),
select the link in the second bullet point that says `Check out the
examples, use-cases and guides`. You get a 404 because the redirect
fails.

### Temporary solution

This PR:

1. Removes stale links from the docs content. Instead of linking to old
pages that redirect, we now link everywhere to the destination we wanted
to redirect them to.
    - Test it:
- In prod, visit [the godaddy
guide](https://ngrok.com/docs/using-ngrok-with/godaddy/) and click the
link text in the second sentence `added a reserved domain`. It should
404.
- In the preview, [visit the same
guide](https://ngrok-docs-git-shaquil-doc-36-swizzle-the-sear-722461-ngrok-dev.vercel.app/docs/using-ngrok-with/godaddy/)
and click the same link. It will 404, then redirect.
    - You can do this for multiple other instances
1. Removes random links that are absolute URLs in the docs content for
no reason. Maybe they were added by folks who didn't realize relative
paths work.
1. Wraps results in the search modal with an `<a>` tag instead of
`<Link>`. We provide the `<a>` with an absolute URL to cause a hard page
load, triggering the redirect script.
1. Makes our redirect script account for trailing slashes
- In some cases, [if we added a redirect with a trailing slash, it would
not work without the
slash](https://ngrok.slack.com/archives/C03LRGNSG6A/p1736871485920399?thread_ts=1736867844.224459&cid=C03LRGNSG6A).
Not sure why, so I just updated the `fromIncludes` method to normalize
the redirect it receives.
    - Test it:
- In prod, visit
[https://ngrok.com/docs/traffic-policy/gallery](https://ngrok.com/docs/traffic-policy/gallery)
(no trailing slash, so it 404s)
- In the preview, [visit the same
route](https://ngrok-docs-git-shaquil-doc-36-swizzle-the-sear-722461-ngrok-dev.vercel.app/docs/traffic-policy/gallery)
- It 404s then redirects because the redirect is client-side. A server
side redirect would prevent this 👍

### Permanent solution (future)

To avoid this in the future, we should implement server-side redirects.
Some googling seems to imply that this is possible with SPAs. If it's
not realistic, we'd have to migrate to a meta framework like Next.js or
Remix to leverage server side redirects.

Slack thread:
- https://ngrok.slack.com/archives/C03LRGNSG6A/p1736867844224459

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
S3Prototype and autofix-ci[bot] authored Jan 15, 2025
1 parent 32b42d0 commit 3f2f720
Show file tree
Hide file tree
Showing 73 changed files with 771 additions and 522 deletions.
70 changes: 35 additions & 35 deletions docs/agent/cli-api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/agent/config/v3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ Traffic Policy enables you to manage, route and secure traffic through configura
more about the individual parts of the Traffic Policy and the available actions here:

- [HTTP Traffic Policy Docs](/docs/http/traffic-policy/)
- [TLS Traffic Policy Docs](/docs/tls/traffic-policy/)
- [TCP Traffic Policy Docs](/docs/tcp/traffic-policy/)
- [TLS Traffic Policy Docs](/traffic-policy)
- [TCP Traffic Policy Docs](/traffic-policy)

##### Example

Expand Down
30 changes: 15 additions & 15 deletions docs/api/resources/edge-route-webhook-verification-module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ PUT /edges/https/\{edge_id\}/routes/\{id\}/webhook_verification

#### Parameters

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

### Response

Expand All @@ -31,11 +31,11 @@ Returns a 200 response on success

#### Fields

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

## Get HTTPS Edge Route Webhook Verification Module

Expand All @@ -53,11 +53,11 @@ Returns a 200 response on success

#### Fields

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

## Delete HTTPS Edge Route Webhook Verification Module

Expand Down
50 changes: 25 additions & 25 deletions docs/api/resources/edges-https-routes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ POST /edges/https/\{edge_id\}/routes

#### EndpointWebhookValidation parameters

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

#### EndpointOAuth parameters

Expand Down Expand Up @@ -342,11 +342,11 @@ Returns a 201 response on success

#### EndpointWebhookValidation fields

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

#### EndpointOAuth fields

Expand Down Expand Up @@ -608,11 +608,11 @@ Returns a 200 response on success

#### EndpointWebhookValidation fields

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

#### EndpointOAuth fields

Expand Down Expand Up @@ -859,11 +859,11 @@ PATCH /edges/https/\{edge_id\}/routes/\{id\}

#### EndpointWebhookValidation parameters

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

#### EndpointOAuth parameters

Expand Down Expand Up @@ -1110,11 +1110,11 @@ Returns a 200 response on success

#### EndpointWebhookValidation fields

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook-verification |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |
| Name | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` if the module will be applied to traffic, `false` to disable. default `true` if unspecified |
| `provider` | string | a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the [supported providers](/http/webhook-verification/) |
| `secret` | string | a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret |

#### EndpointOAuth fields

Expand Down
Loading

0 comments on commit 3f2f720

Please sign in to comment.