stack/docs/next.config.mjs
Madison 3538638406
[Docs][Site] + [Dashboard][UI] - Adds docs to Stack Companion (#869)
<!--

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

-->

<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> Adds a unified documentation widget to the dashboard, enabling in-app
viewing and switching of documentation types with platform-specific
adaptations.
> 
>   - **Behavior**:
> - Adds `UnifiedDocsWidget` to `stack-companion.tsx` for viewing docs
within the dashboard.
> - Supports platform switching, back navigation, sidebar toggle,
loading/error states, and external opening.
> - Adapts content based on current page across dashboard, docs, and
API.
>   - **Documentation**:
> - Adds embedded routes/layouts in `docs/src/app` for `api-embed`,
`dashboard-embed`, and `docs-embed`.
> - Implements `EmbeddedLinkInterceptor` and `PlatformChangeNotifier`
for link handling and platform change notifications.
>     - Updates `generate-docs.js` to include dashboard docs generation.
>   - **Configuration**:
> - Adds `NEXT_PUBLIC_STACK_DOCS_BASE_URL` to `.env.development` and
`env.tsx`.
> - Configures CORS headers in `next.config.mjs` for dashboard
embedding.
>   - **Misc**:
>     - Updates styling in `global.css` to support embedded content.
> - Adds `EmbeddedLink` component for MDX link handling in
`mdx-components.tsx`.
> 
> <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 5760b90ea6. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>

----


<!-- ELLIPSIS_HIDDEN -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Unified embedded docs viewer added to the dashboard with multi-type
support, navigation controls, back navigation, and external-open
behavior
* In-iframe link interception and MDX embedded-link support for seamless
embedded navigation

* **Style**
* Improved CSS for embedded content: scrollbar hiding, overflow
handling, responsive media and code blocks

* **Chores**
* Added dashboard docs collection, embed routes/layouts, CORS headers,
and env config for docs embedding

* **UX**
* Consolidated account UI in mobile header; improved auth panel
open/close animations
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
2025-10-30 20:01:30 -05:00

109 lines
2.9 KiB
JavaScript

import { createMDX } from 'fumadocs-mdx/next';
const withMDX = createMDX();
const dashboardUrl = process.env.NEXT_PUBLIC_STACK_DASHBOARD_URL || 'http://localhost:8101';
/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
eslint: {
// Temporarily disable ESLint during builds for Vercel deployment
ignoreDuringBuilds: false,
},
async headers() {
return [
{
// Allow CORS for dashboard routes to be accessed by the dashboard app
source: '/dashboard/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: dashboardUrl, // Dashboard app origin
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET, POST, PUT, DELETE, OPTIONS',
},
{
key: 'Access-Control-Allow-Headers',
value: 'Content-Type, Authorization',
},
],
},
{
// Allow CORS for embedded dashboard routes to be accessed by the dashboard app
source: '/dashboard-embed/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: dashboardUrl, // Dashboard app origin
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET, POST, PUT, DELETE, OPTIONS',
},
{
key: 'Access-Control-Allow-Headers',
value: 'Content-Type, Authorization',
},
],
},
];
},
// Include OpenAPI files in output tracing for Vercel deployments
outputFileTracingIncludes: {
'/**/*': ['./content/**/*', './openapi/**/*'],
},
async redirects() {
return [
// Redirect root to docs overview
{
source: '/',
destination: '/docs/overview',
permanent: false,
},
// 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);