From 13134f801cf676765d6c551f6bf5923c667bb3d5 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 14 Mar 2025 17:06:57 -0700 Subject: [PATCH] fix: remove duplicate middleware, add some docs content --- docs/app/docs/layout.tsx | 8 +++++- docs/content/docs/execution/index.mdx | 6 +---- sim/app/middleware.ts | 37 --------------------------- sim/middleware.ts | 14 ++-------- 4 files changed, 10 insertions(+), 55 deletions(-) delete mode 100644 sim/app/middleware.ts diff --git a/docs/app/docs/layout.tsx b/docs/app/docs/layout.tsx index 4dfbae8e0d..dfeda22a97 100644 --- a/docs/app/docs/layout.tsx +++ b/docs/app/docs/layout.tsx @@ -3,6 +3,7 @@ import Link from 'next/link' import { DocsLayout } from 'fumadocs-ui/layouts/docs' import { GithubIcon } from 'lucide-react' import { source } from '@/lib/source' +import { AgentIcon } from '@/components/icons' const GitHubLink = () => (
@@ -23,7 +24,12 @@ export default function Layout({ children }: { children: ReactNode }) { + + Sim Studio +
+ ), }} > {children} diff --git a/docs/content/docs/execution/index.mdx b/docs/content/docs/execution/index.mdx index ddbb96c926..2a5e18f136 100644 --- a/docs/content/docs/execution/index.mdx +++ b/docs/content/docs/execution/index.mdx @@ -1,6 +1,6 @@ --- title: Execution -description: The execution of a workflow. +description: Sim Studio provides a powerful execution engine that brings your workflows to life. Understanding how execution works will help you design more effective workflows and troubleshoot any issues that arise.. --- import { Card, Cards } from 'fumadocs-ui/components/card' @@ -10,10 +10,6 @@ import { Accordion, Accordions } from 'fumadocs-ui/components/accordion' import { Tab, Tabs } from 'fumadocs-ui/components/tabs' import { AgentIcon, ApiIcon, ConditionalIcon, CodeIcon, ChartBarIcon, ConnectIcon, GmailIcon, PerplexityIcon, NotionIcon, ExaAIIcon, FirecrawlIcon, SlackIcon } from '@/components/icons' -# Workflow Execution - -Sim Studio provides a powerful execution engine that brings your workflows to life. Understanding how execution works will help you design more effective workflows and troubleshoot any issues that arise. - ## Execution Flow When you execute a workflow in Sim Studio, the system follows a predictable pattern: diff --git a/sim/app/middleware.ts b/sim/app/middleware.ts deleted file mode 100644 index fa2ea28465..0000000000 --- a/sim/app/middleware.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { NextRequest, NextResponse } from 'next/server' - -export async function middleware(request: NextRequest) { - // Check if the path is exactly /w - if (request.nextUrl.pathname === '/w') { - return NextResponse.redirect(new URL('/w/1', request.url)) - } - - // Skip auth check if DISABLE_AUTH is set (for standalone mode) - if (process.env.DISABLE_AUTH === 'true' || process.env.NEXT_PUBLIC_DISABLE_AUTH === 'true') { - return NextResponse.next() - } - - const cookieHeader = request.headers.get("cookie"); - const cookies = cookieHeader?.split("; ").reduce((acc, cookie) => { - const [key, value] = cookie.split("="); - acc.set(key, value); - return acc; - }, new Map()); - - const sessionCookie = - cookies?.get("better-auth.session_token") || - cookies?.get("__Secure-better-auth.session_token"); - - if (!sessionCookie) { - return NextResponse.redirect(new URL('/login', request.url)) - } - return NextResponse.next() -} - -// TODO: Add protected routes -export const config = { - matcher: [ - '/w', // Match exactly /w - '/w/:path*', // Keep existing matcher for protected routes - ], -} diff --git a/sim/middleware.ts b/sim/middleware.ts index c9f311e43a..b4989e45c0 100644 --- a/sim/middleware.ts +++ b/sim/middleware.ts @@ -1,4 +1,5 @@ import { NextRequest, NextResponse } from 'next/server' +import { getSessionCookie } from "better-auth/cookies" export async function middleware(request: NextRequest) { // Check if the path is exactly /w @@ -11,18 +12,7 @@ export async function middleware(request: NextRequest) { return NextResponse.next() } - const cookieHeader = request.headers.get("cookie"); - const cookies = cookieHeader?.split("; ").reduce((acc, cookie) => { - const [key, value] = cookie.split("="); - acc.set(key, value); - return acc; - }, new Map()); - - const sessionCookie = - cookies?.get("better-auth.session_token") || - cookies?.get("__Secure-better-auth.session_token"); - - // Existing auth check for protected routes + const sessionCookie = getSessionCookie(request) if (!sessionCookie) { return NextResponse.redirect(new URL('/login', request.url)) }