Skip to content

Conversation

madster456
Copy link
Collaborator

@madster456 madster456 commented Jul 24, 2025

quick fix for broken URLs old deep links. RIght now, redirect to overview for api deep links, and for old docs deep links, redirects to /docs/next/overview.


Important

Adds catch-all redirect logic in page.tsx for old documentation links, updating next.config.mjs to reflect this change.

  • Behavior:
    • Adds catch-all redirect logic in page.tsx to handle old documentation links, redirecting to relevant sections based on URL patterns.
    • Redirects API-related paths to /api/overview.
    • Redirects SDK, Components, Getting Started, Concepts, and Customization paths to /docs/{platform}/ respective sections.
    • Redirects Others, FAQ, and Overview paths to /docs/{platform}/overview.
    • Default platform is next, with detection for react, js, and python.
  • Configuration:
    • Updates next.config.mjs to note that other redirects are handled by page.tsx.

This description was created by Ellipsis for 9e26b23. You can customize this summary. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stack-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 11:51am
stack-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 11:51am
stack-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 11:51am
stack-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 11:51am

import { redirect } from 'next/navigation';

type Props = {
params: Promise<{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The params type is incorrectly defined as a Promise. In Next.js, page parameters for dynamic routes are passed as direct values, not promises. The type should be { params: { slug: string[] } }. The unnecessary Promise type and await operation could cause type checking issues and unnecessary asynchronous operations. This could lead to runtime errors if the code is used in a context where Promise handling is not properly implemented.

📚 Relevant Docs

Suggested change
params: Promise<{
params: {

React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)

Copy link

recurseml bot commented Jul 24, 2025

😱 Found 1 issue. Time to roll up your sleeves! 😱

🗒️ View all ignored comments in this repo
  • The constraint 'TokenStoreType extends string' is too restrictive. It should likely be 'TokenStoreType extends string | object' to match the condition check in line 113 where TokenStoreType is checked against {}
  • Return type mismatch - the interface declares useUsers() returning ServerUser[] but the Team interface that this extends declares useUsers() returning TeamUser[]
  • There is a syntax error in the super constructor call due to the ellipsis operator used incorrectly. Objects aren't being merged correctly. This syntax usage can lead to runtime errors when trying to pass the merged object to 'super()'. Verify that the intended alterations to the object occur before or outside of the super() call if needed.
  • Throwing an error when no active span is found is too aggressive. The log function should gracefully fallback to console.log or another logging mechanism when there's no active span, since not all execution contexts will have an active span. This makes the code less resilient and could break functionality in non-traced environments.

📚 Relevant Docs

  • Function sets backendContext with a new configuration but doesn't pass 'defaultProjectKeys'. Since defaultProjectKeys is required in the type definition and cannot be updated (throws error if tried to set), this will cause a type error.
  • The schema is using array syntax for pick() which is incorrect for Yup schemas. The pick() method in Yup expects individual arguments, not an array. Should be changed to: emailConfigSchema.pick('type', 'host', 'port', 'username', 'sender_name', 'sender_email')

📚 Relevant Docs

  • Creating a refresh token with current timestamp as expiration means it expires immediately. Should set a future date for token expiration.
  • The 'tools' object is initialized as an empty object, even though 'tools' is presumably expected to contain tool definitions. This could cause the server capabilities to lack necessary tool configurations, thus potentially impacting functionalities that depend on certain tool setups.

📚 Relevant Docs

  • 'STACK_SECRET_SERVER_KEY' is potentially being included in every request header without checking its existence again here. Although it's checked during initialization, this could lead to security issues as it's exposed in all communications where the header is logged or captured.

📚 Relevant Docs

  • When adding 'use client' directive at the beginning, it doesn't check if file.text already contains the 'use client' directive. This could lead to duplicate 'use client' directives if the file already has one.

📚 Relevant Docs

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR adds a redirect system to handle broken old documentation links by implementing a catch-all route strategy. The main changes include:

  1. Catch-all Route Implementation: A new [...slug]/page.tsx file intercepts unmatched routes and redirects them to appropriate documentation sections based on URL pattern matching.

  2. Platform Detection Logic: The system attempts to detect the intended platform (next, react, js, python) from URL patterns using string matching on the slug array.

  3. Section Mapping: Common documentation sections like SDK, components, getting-started, concepts, etc. are mapped to their new locations in the current URL structure (/docs/{platform}/{section}).

  4. Fallback Strategy: All redirects ultimately fall back to /docs/{platform}/overview to ensure users never encounter 404 errors.

  5. Config Update: The next.config.mjs file is updated with a comment indicating that redirects are now handled by the catch-all route instead of explicit configuration.

This approach replaces the need to maintain exhaustive URL mappings in the Next.js config with a more flexible pattern-based system that can handle various URL structures dynamically. The implementation ensures backward compatibility for old bookmarks and external links while directing users to the most relevant documentation sections.

Confidence score: 3/5

• This PR has moderate complexity with potential edge cases in the redirect logic that could cause unexpected behavior
• The platform detection logic uses simple string matching which may not handle all URL variations correctly, and some redirect conditions could conflict
• The [...slug]/page.tsx file needs more attention due to complex conditional logic and potential for infinite redirect loops

2 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Comment on lines +19 to +24
if (path.startsWith('react/') || path.includes('/react/')) {
platform = 'react';
} else if (path.startsWith('js/') || path.includes('/js/')) {
platform = 'js';
} else if (path.startsWith('python/') || path.includes('/python/')) {
platform = 'python';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Platform detection uses includes() which could cause false positives. Path /docs/react-native/guide would incorrectly detect as 'react' platform

import { redirect } from 'next/navigation';

type Props = {
params: Promise<{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider revising the Props type. In Next.js app directory, the route params are passed synchronously (i.e. { slug: string[] }) so wrapping it in a Promise and awaiting it may be unnecessary.


// Handle API routes → /api/overview
if (path.startsWith('next/rest-api/') || path.startsWith('rest-api/') || path.includes('/rest-api/')) {
redirect('/api/overview');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For constructing redirect URLs, consider using a tagged template literal (e.g. urlString) to safely interpolate dynamic segments per our URL guidelines.

This comment was generated because it violated a code review rule: mrule_pmzJAgHDlFZgwIwD.

@madster456 madster456 closed this Jul 25, 2025
@madster456
Copy link
Collaborator Author

this PR is replaced with #804

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants