Commit Graph

9 Commits

Author SHA1 Message Date
Charis
9d9fdcd9fc feat (docs): on-demand revalidation for graphql and wrappers (#35177)
Before:

Revalidation was turned off entirely for wrappers pages, and done daily for GraphQL pages.

After:

Revalidation is via tag. There is an /api/revalidate endpoint that is used by GitHub Actions on the federated repos to trigger the revalidation. This decreases the number of unnecessary page generations by Vercel, and gives the maintainers of federated repos more fine-grained control over when to reploy their docs (see the docs deployment playbook for more info).
2025-04-24 14:59:38 -04:00
Charis
39a12342ea fix (docs): middleware rewrites for reference pages (#35201)
Before:

There was a bug with middleware rewrites for reference pages without
crawler versions (basically all references except the client SDKs).
There was a branch that was not handled (the requesting user agent is a
a bot, but the reference is not a client SDK), so it failed through to
the base case of NextResponse.next(), which 404s as that page does not
exist for a path like /reference/api/v1-deploy-a-function

After:

Fixed the branch. If all of the following are true:

- Is a reference page
- Requesting user agent is a bot
- Reference is not a client SDK

Then it should follow the same path as a non-bot request, because there
is no bot-specific version. That means it should be rewritten to teh
slugless page: /reference/api/v1-deploya-function => /reference/api
2025-04-22 10:14:02 -04:00
Charis
3f08a033d9 fix: autofix action (#30421)
Autofix action is failing with error message:

```
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

    git push origin HEAD:<name-of-remote-branch>
```

This is because the checkout action on a PR by default checks out the merge commit, which is not a branch. Instead, check out [`github.head_ref`](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context), which will point to the source of the PR.

---------

Co-authored-by: github-tidy-bot <github-tidy-bot@supabase.com>
2024-11-11 16:18:42 -05:00
Charis
762c52b2f1 fix(docs): error handling in revalidate api (#29402) 2024-09-20 12:14:54 -04:00
Charis
dfda9da26d feat(docs): add revalidation api route (#29378)
Add a route for manually revalidating cache contents by tag.

The route is protected by authentication to prevent abuse. Automated
actions in CI should be set up with a basic API key, which has a rate
limit of 6 hours between changes. Overriding is possible with an
override key, which should be used as an escape hatch.

Usage:
- API key provided in header `Authorization: Bearer <KEY>`
- Body has shape `{ tags: string[] }`
2024-09-19 14:28:07 -04:00
Charis
5d2bdc9efb refactor(docs): move last pages over to app router (#29293)
The end of the Great Migration is here!!!

Moves the last pages over, deleting pages like the FAQ that we don't use
and that contain duplicated information anyway.

Dev secret auth page URL had to change as App Router doesn't like the
leading underscores in the path.

Also fixes the not-found recommendations to use the proper Next.js
not-found page so it will return a 404 as it should. (I was under the
erroneous impression that I couldn't get the pathname in not-found.tsx,
that is not true, so this works better.)
2024-09-13 13:28:15 -04:00
Charis
84a8fa7ac3 refactor(docs): migrate cli reference to app router (#29117) 2024-09-06 09:22:25 -04:00
Charis
e67c219120 fix(docs): api crawler routes (#28614) 2024-08-14 12:16:02 -04:00
Charis
fc164b5d07 Refactor/app router refs (#28095)
Migrates client SDK References to App Router. (Management and CLI API references aren't migrated yet, nor are self-hosting config references.)

Some notes:

Big changes to the way crawler pages are built and individual section URLs (e.g., javascript/select) are served. All of these used to be SSG-generated pages, but the number of heavy pages was just too much to handle -- slow as molasses and my laptop sounded like it was taking off, and CI sometimes refuses to build it all at all.

Tried various tricks with caching and pre-generating data but no dice.

So I changed to only building one copy of each SDK+version page, then serving the sub-URLs through a response rewrite. That's for the actual user-visible pages.

For the bot pages, each sub-URL needs to be its own page, but prebuilding it doesn't work, and rendering on demand from React components is too slow (looking for super-fast response here for SEO). Instead I changed to using an API route that serves very minimal, hand-crafted HTML. It looks ugly, but it's purely for the search bots.

You can test what bots see by running curl --user-agent "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" <URL_OF_PAGE>

Also added some smoke tests to run against prod for the crawler routes, since we don't keep an eye on those regularly, and Vercel config changes could surprise-break them. Tested the meta images on Open Graph and all seems to work fine.

With this approach, full production builds are really fast: ~5 minutes

Starts using the new type spec handling, which is better at finding params automatically, so I could remove some of the manually written ones from the spec files.
2024-08-13 16:12:59 -04:00