stack/docs/next.config.mjs
Madison 48c6f47448
Add API docs to llms.txt file. (#766)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

Adds API docs to the llms.txt file for our agent to reference. Before,
it was not capturing this information about the API.

<!-- ELLIPSIS_HIDDEN -->

----

> [!IMPORTANT]
> Adds OpenAPI documentation extraction and formatting to
`get-llm-text.ts` and updates Next.js configuration for ESLint and
OpenAPI file handling.
> 
>   - **Behavior**:
> - Adds `extractOpenAPIContent()` in `get-llm-text.ts` to extract
OpenAPI content from API pages.
> - Formats OpenAPI operations and specs using `formatOperation()` and
`formatOpenAPISpec()`.
> - Updates `getLLMText()` to return formatted OpenAPI content if
available.
>   - **Configuration**:
> - Changes `ignoreDuringBuilds` to `false` in `next.config.mjs` to
enable ESLint during builds.
> - Includes OpenAPI files in `outputFileTracingIncludes` for Vercel
deployments in `next.config.mjs`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for f3b3d75a35. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->

---------

Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
2025-07-15 11:13:32 -05:00

63 lines
1.6 KiB
JavaScript

import { createMDX } from 'fumadocs-mdx/next';
const withMDX = createMDX();
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
eslint: {
// Temporarily disable ESLint during builds for Vercel deployment
ignoreDuringBuilds: false,
},
// Include OpenAPI files in output tracing for Vercel deployments
outputFileTracingIncludes: {
'/api/**/*': ['./openapi/**/*'],
'/**/*': ['./openapi/**/*'],
},
async redirects() {
return [
// Redirect /docs/api to the overview page
{
source: '/docs/api',
destination: '/docs/api/overview',
permanent: false,
},
];
},
async rewrites() {
return [
// PostHog proxy rewrites to prevent ad blockers
{
source: "/consume/static/:path*",
destination: "https://eu-assets.i.posthog.com/static/:path*",
},
{
source: "/consume/:path*",
destination: "https://eu.i.posthog.com/:path*",
},
{
source: "/consume/decide",
destination: "https://eu.i.posthog.com/decide",
},
// Redirect .mdx requests to the llms.mdx route handler
{
source: '/docs/:path*.mdx',
destination: '/llms.mdx/:path*',
},
{
source: '/api/:path*.mdx',
destination: '/llms.mdx/:path*',
},
// Serve OpenAPI files from the openapi directory
{
source: '/openapi/:path*',
destination: '/openapi/:path*',
},
// No other rewrites needed for API docs - they're served directly from /docs/api/*
];
},
};
export default withMDX(config);